|
18 | 18 | import org.jetbrains.annotations.NotNull; |
19 | 19 | import org.labkey.api.attachments.AttachmentParentType; |
20 | 20 | import org.labkey.api.data.SQLFragment; |
| 21 | +import org.labkey.api.data.dialect.SqlDialect; |
21 | 22 | import org.labkey.api.exp.PropertyType; |
22 | 23 | import org.labkey.api.exp.list.ListDefinition; |
23 | 24 | import org.labkey.api.exp.list.ListService; |
24 | 25 | import org.labkey.api.exp.property.Domain; |
25 | 26 | import org.labkey.api.exp.property.PropertyService; |
26 | 27 | import org.labkey.list.model.IntegerListDomainKind; |
| 28 | +import org.labkey.list.model.ListSchema; |
27 | 29 | import org.labkey.list.model.PicklistDomainKind; |
28 | 30 | import org.labkey.list.model.VarcharListDomainKind; |
29 | 31 |
|
@@ -56,15 +58,22 @@ private ListItemType() |
56 | 58 | { |
57 | 59 | ListService svc = ListService.get(); |
58 | 60 | assert null != svc; |
59 | | - |
| 61 | + SqlDialect dialect = ListSchema.getInstance().getSchema().getSqlDialect(); |
60 | 62 | List<SQLFragment> selectStatements = new LinkedList<>(); |
61 | 63 |
|
62 | 64 | PropertyService.get().getContainersWithDomains(Set.of(IntegerListDomainKind.NAMESPACE_PREFIX, VarcharListDomainKind.NAMESPACE_PREFIX, PicklistDomainKind.NAMESPACE_PREFIX)).forEach(c -> { |
63 | 65 | Map<String, ListDefinition> map = svc.getLists(c, null, false); |
64 | 66 | map.forEach((k, v) -> { |
65 | 67 | Domain domain = v.getDomain(); |
66 | 68 | if (null != domain && domain.getProperties().stream().anyMatch(p -> p.getPropertyType() == PropertyType.ATTACHMENT)) |
67 | | - selectStatements.add(new SQLFragment("\n SELECT EntityId, ? AS Description FROM list.", domain.getName()).append(domain.getStorageTableName())); |
| 69 | + selectStatements.add(new SQLFragment("\n SELECT EntityId, ") |
| 70 | + .append(dialect.concatenate( |
| 71 | + new SQLFragment("?", domain.getName()), |
| 72 | + new SQLFragment("':'"), |
| 73 | + new SQLFragment("CAST(").append(dialect.makeDatabaseIdentifier(v.getKeyName()).getSql())).append(" AS VARCHAR)") |
| 74 | + ) |
| 75 | + .append(" AS Description FROM list.").append(domain.getStorageTableName()) |
| 76 | + ); |
68 | 77 | }); |
69 | 78 | }); |
70 | 79 |
|
|
0 commit comments