Skip to content

Commit 1f5b95c

Browse files
akoclaude
andcommitted
feat: rename catalog modules.IsSystemModule to Source text column (#82)
The IsSystemModule column was misleading — it was set from Module.FromAppStore, not from being a System module. Replace with a Source TEXT column containing descriptive values: "" — user-created module "Marketplace v4.3.2" — marketplace module with version "Marketplace" — marketplace module (no version) This matches the Source column already shown by SHOW MODULES and is more useful for catalog queries: SELECT name FROM catalog.modules WHERE source = ''; SELECT name FROM catalog.modules WHERE source LIKE 'Marketplace%'; Updated all references: - catalog/tables.go: schema definition - catalog/builder_modules.go: insert logic - linter/context.go: 10 queries filtering user modules - executor/cmd_structure.go: SHOW STRUCTURE module filtering - visitor/visitor_catalog_test.go: test query Fixes #82 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 425dfdb commit 1f5b95c

5 files changed

Lines changed: 25 additions & 21 deletions

File tree

mdl/catalog/builder_modules.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func (b *Builder) buildModules() error {
1717

1818
stmt, err := b.tx.Prepare(`
1919
INSERT INTO modules (Id, Name, QualifiedName, ModuleName, Folder, Description,
20-
IsSystemModule, AppStoreVersion, AppStoreGuid,
20+
Source, AppStoreVersion, AppStoreGuid,
2121
ProjectId, ProjectName, SnapshotId, SnapshotDate, SnapshotSource,
2222
SourceId, SourceBranch, SourceRevision)
2323
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
@@ -30,9 +30,13 @@ func (b *Builder) buildModules() error {
3030
projectID, projectName, snapshotID, snapshotDate, snapshotSource, sourceID, sourceBranch, sourceRevision := b.snapshotMeta()
3131

3232
for _, m := range modules {
33-
isSystem := 0
33+
source := ""
3434
if m.FromAppStore {
35-
isSystem = 1
35+
if m.AppStoreVersion != "" {
36+
source = "Marketplace v" + m.AppStoreVersion
37+
} else {
38+
source = "Marketplace"
39+
}
3640
}
3741
_, err := stmt.Exec(
3842
string(m.ID),
@@ -41,7 +45,7 @@ func (b *Builder) buildModules() error {
4145
"", // ModuleName empty for modules
4246
"", // Folder
4347
m.Documentation,
44-
isSystem,
48+
source,
4549
m.AppStoreVersion,
4650
m.AppStoreGuid,
4751
projectID, projectName, snapshotID, snapshotDate, snapshotSource,

mdl/catalog/tables.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (c *Catalog) createTables() error {
4444
ModuleName TEXT,
4545
Folder TEXT,
4646
Description TEXT,
47-
IsSystemModule INTEGER DEFAULT 0,
47+
Source TEXT DEFAULT '',
4848
AppStoreVersion TEXT,
4949
AppStoreGuid TEXT,
5050
ProjectId TEXT,

mdl/executor/cmd_structure.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type structureModule struct {
5959

6060
// getStructureModules returns filtered and sorted modules for structure output.
6161
func (e *Executor) getStructureModules(filterModule string, includeAll bool) ([]structureModule, error) {
62-
result, err := e.catalog.Query("SELECT Id, Name, IsSystemModule, AppStoreGuid FROM modules ORDER BY Name")
62+
result, err := e.catalog.Query("SELECT Id, Name, Source, AppStoreGuid FROM modules ORDER BY Name")
6363
if err != nil {
6464
return nil, fmt.Errorf("failed to query modules: %w", err)
6565
}
@@ -68,7 +68,7 @@ func (e *Executor) getStructureModules(filterModule string, includeAll bool) ([]
6868
for _, row := range result.Rows {
6969
id := asString(row[0])
7070
name := asString(row[1])
71-
isSystem := asString(row[2])
71+
source := asString(row[2])
7272
appStoreGuid := asString(row[3])
7373

7474
// Filter by module name if specified
@@ -77,7 +77,7 @@ func (e *Executor) getStructureModules(filterModule string, includeAll bool) ([]
7777
}
7878

7979
// Skip system/marketplace modules unless --all
80-
if !includeAll && !isUserModule(name, isSystem, appStoreGuid) {
80+
if !includeAll && !isUserModule(name, source, appStoreGuid) {
8181
continue
8282
}
8383

@@ -92,8 +92,8 @@ func (e *Executor) getStructureModules(filterModule string, includeAll bool) ([]
9292
}
9393

9494
// isUserModule returns true if the module is a user-created module (not system or marketplace).
95-
func isUserModule(name, isSystem, appStoreGuid string) bool {
96-
if isSystem == "1" {
95+
func isUserModule(name, source, appStoreGuid string) bool {
96+
if source != "" {
9797
return false
9898
}
9999
if appStoreGuid != "" {

mdl/linter/context.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (ctx *LintContext) Entities() iter.Seq[Entity] {
9898
e.HasEventHandlers, e.IsExternal
9999
FROM entities e
100100
LEFT JOIN modules m ON e.ModuleName = m.Name
101-
WHERE COALESCE(m.IsSystemModule, 0) = 0
101+
WHERE COALESCE(m.Source, '') = ''
102102
ORDER BY e.ModuleName, e.Name
103103
`)
104104
if err != nil {
@@ -402,7 +402,7 @@ func (ctx *LintContext) Microflows() iter.Seq[Microflow] {
402402
mf.ParameterCount, mf.ActivityCount, mf.Complexity
403403
FROM microflows mf
404404
LEFT JOIN modules m ON mf.ModuleName = m.Name
405-
WHERE COALESCE(m.IsSystemModule, 0) = 0
405+
WHERE COALESCE(m.Source, '') = ''
406406
ORDER BY mf.ModuleName, mf.Name
407407
`)
408408
if err != nil {
@@ -454,7 +454,7 @@ func (ctx *LintContext) Pages() iter.Seq[Page] {
454454
p.Title, p.URL, p.Description, p.WidgetCount
455455
FROM pages p
456456
LEFT JOIN modules m ON p.ModuleName = m.Name
457-
WHERE COALESCE(m.IsSystemModule, 0) = 0
457+
WHERE COALESCE(m.Source, '') = ''
458458
ORDER BY p.ModuleName, p.Name
459459
`)
460460
if err != nil {
@@ -507,7 +507,7 @@ func (ctx *LintContext) Enumerations() iter.Seq[Enumeration] {
507507
en.Description, en.ValueCount
508508
FROM enumerations en
509509
LEFT JOIN modules m ON en.ModuleName = m.Name
510-
WHERE COALESCE(m.IsSystemModule, 0) = 0
510+
WHERE COALESCE(m.Source, '') = ''
511511
ORDER BY en.ModuleName, en.Name
512512
`)
513513
if err != nil {
@@ -558,7 +558,7 @@ func (ctx *LintContext) Widgets() iter.Seq[Widget] {
558558
w.ContainerType, w.ModuleName, w.EntityRef, w.AttributeRef
559559
FROM widgets w
560560
LEFT JOIN modules m ON w.ModuleName = m.Name
561-
WHERE COALESCE(m.IsSystemModule, 0) = 0
561+
WHERE COALESCE(m.Source, '') = ''
562562
ORDER BY w.ModuleName, w.ContainerQualifiedName, w.Name
563563
`)
564564
if err != nil {
@@ -608,7 +608,7 @@ func (ctx *LintContext) Snippets() iter.Seq[Snippet] {
608608
SELECT s.Id, s.Name, s.QualifiedName, s.ModuleName, s.Folder, s.WidgetCount
609609
FROM snippets s
610610
LEFT JOIN modules m ON s.ModuleName = m.Name
611-
WHERE COALESCE(m.IsSystemModule, 0) = 0
611+
WHERE COALESCE(m.Source, '') = ''
612612
ORDER BY s.ModuleName, s.Name
613613
`)
614614
if err != nil {
@@ -657,7 +657,7 @@ func (ctx *LintContext) DatabaseConnections() iter.Seq[DatabaseConnection] {
657657
dc.DatabaseType, dc.QueryCount
658658
FROM database_connections dc
659659
LEFT JOIN modules m ON dc.ModuleName = m.Name
660-
WHERE COALESCE(m.IsSystemModule, 0) = 0
660+
WHERE COALESCE(m.Source, '') = ''
661661
ORDER BY dc.ModuleName, dc.Name
662662
`)
663663
if err != nil {
@@ -792,7 +792,7 @@ func (ctx *LintContext) FindUnused(kind string) []string {
792792
SELECT e.QualifiedName
793793
FROM entities e
794794
LEFT JOIN modules m ON e.ModuleName = m.Name
795-
WHERE COALESCE(m.IsSystemModule, 0) = 0
795+
WHERE COALESCE(m.Source, '') = ''
796796
AND e.QualifiedName NOT IN (
797797
SELECT DISTINCT TargetName FROM refs WHERE TargetType = 'ENTITY'
798798
)
@@ -802,7 +802,7 @@ func (ctx *LintContext) FindUnused(kind string) []string {
802802
SELECT mf.QualifiedName
803803
FROM microflows mf
804804
LEFT JOIN modules m ON mf.ModuleName = m.Name
805-
WHERE COALESCE(m.IsSystemModule, 0) = 0
805+
WHERE COALESCE(m.Source, '') = ''
806806
AND mf.QualifiedName NOT IN (
807807
SELECT DISTINCT TargetName FROM refs WHERE TargetType IN ('MICROFLOW', 'NANOFLOW')
808808
)
@@ -812,7 +812,7 @@ func (ctx *LintContext) FindUnused(kind string) []string {
812812
SELECT p.QualifiedName
813813
FROM pages p
814814
LEFT JOIN modules m ON p.ModuleName = m.Name
815-
WHERE COALESCE(m.IsSystemModule, 0) = 0
815+
WHERE COALESCE(m.Source, '') = ''
816816
AND p.QualifiedName NOT IN (
817817
SELECT DISTINCT TargetName FROM refs WHERE TargetType = 'PAGE'
818818
)

mdl/visitor/visitor_catalog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestSelectFromCatalog(t *testing.T) {
5858
input string
5959
}{
6060
{"simple select", "SELECT * FROM CATALOG.ENTITIES;"},
61-
{"with where", "SELECT Name, ModuleName FROM CATALOG.MODULES WHERE IsSystemModule = 0;"},
61+
{"with where", "SELECT Name, ModuleName FROM CATALOG.MODULES WHERE Source = '';"},
6262
{"lowercase", "select * from catalog.microflows;"},
6363
{"with alias", "SELECT e.Name FROM CATALOG.ENTITIES e;"},
6464
{"with join", "SELECT e.Name, a.Name FROM CATALOG.ENTITIES e JOIN CATALOG.ATTRIBUTES a ON e.Id = a.EntityId;"},

0 commit comments

Comments
 (0)