diff --git a/dc-agents/sqlite/src/schema.ts b/dc-agents/sqlite/src/schema.ts index 0e902025638..1ec204e6360 100644 --- a/dc-agents/sqlite/src/schema.ts +++ b/dc-agents/sqlite/src/schema.ts @@ -38,9 +38,8 @@ function determineScalarType(datatype: Datatype): ScalarTypeKey { } } -function getColumns(ast: any[], primaryKeys: string[]) : ColumnInfo[] { +function getColumns(ast: any[]) : ColumnInfo[] { return ast.map(column => { - const isPrimaryKey = primaryKeys.includes(column.name); const isAutoIncrement = column.definition.some((def: any) => def.type === "constraint" && def.autoIncrement === true); return { @@ -48,7 +47,7 @@ function getColumns(ast: any[], primaryKeys: string[]) : ColumnInfo[] { type: determineScalarType(column.datatype), nullable: nullableCast(column.definition), insertable: MUTATIONS, - updatable: MUTATIONS && !isPrimaryKey, + updatable: MUTATIONS, ...(isAutoIncrement ? { value_generated: { type: "auto_increment" } } : {}) }; }) @@ -78,7 +77,7 @@ const formatTableInfo = (config: Config) => (info: TableInfoInternal): TableInfo ...primaryKey, ...foreignKey, description: info.sql, - columns: getColumns(columnsDdl, primaryKeys), + columns: getColumns(columnsDdl), insertable: MUTATIONS, updatable: MUTATIONS, deletable: MUTATIONS, diff --git a/server/lib/api-tests/src/Test/DataConnector/MetadataApiSpec.hs b/server/lib/api-tests/src/Test/DataConnector/MetadataApiSpec.hs index b31d10ab6a1..ba19992a062 100644 --- a/server/lib/api-tests/src/Test/DataConnector/MetadataApiSpec.hs +++ b/server/lib/api-tests/src/Test/DataConnector/MetadataApiSpec.hs @@ -173,7 +173,7 @@ schemaInspectionTests = describe "Schema and Source Inspection" $ do nullable: false type: *_stIntegerType insertable: *supportsInserts - updatable: false + updatable: *supportsUpdates value_generated: type: auto_increment - name: *artistId diff --git a/server/lib/dc-api/test/Test/Data/schema-tables.json b/server/lib/dc-api/test/Test/Data/schema-tables.json index 911bcddc93c..3397f018e40 100644 --- a/server/lib/dc-api/test/Test/Data/schema-tables.json +++ b/server/lib/dc-api/test/Test/Data/schema-tables.json @@ -11,7 +11,7 @@ "nullable": false, "description": "Genre primary key identifier", "insertable": true, - "updatable": false, + "updatable": true, "value_generated": { "type": "auto_increment" } }, { @@ -39,7 +39,7 @@ "nullable": false, "description": "Media Type primary key identifier", "insertable": true, - "updatable": false, + "updatable": true, "value_generated": { "type": "auto_increment" } }, { @@ -67,7 +67,7 @@ "nullable": false, "description": "Artist primary key identifier", "insertable": true, - "updatable": false, + "updatable": true, "value_generated": { "type": "auto_increment" } }, { @@ -103,7 +103,7 @@ "nullable": false, "description": "Album primary key identifier", "insertable": true, - "updatable": false, + "updatable": true, "value_generated": { "type": "auto_increment" } }, { @@ -159,7 +159,7 @@ "nullable": false, "description": "The ID of the track", "insertable": true, - "updatable": false, + "updatable": true, "value_generated": { "type": "auto_increment" } }, { @@ -251,7 +251,7 @@ "nullable": false, "description": "Employee primary key identifier", "insertable": true, - "updatable": false, + "updatable": true, "value_generated": { "type": "auto_increment" } }, { @@ -391,7 +391,7 @@ "nullable": false, "description": "Customer primary key identifier", "insertable": true, - "updatable": false, + "updatable": true, "value_generated": { "type": "auto_increment" } }, { @@ -515,7 +515,7 @@ "nullable": false, "description": "Invoice primary key identifier", "insertable": true, - "updatable": false, + "updatable": true, "value_generated": { "type": "auto_increment" } }, { @@ -613,7 +613,7 @@ "nullable": false, "description": "Invoice Line primary key identifier", "insertable": true, - "updatable": false, + "updatable": true, "value_generated": { "type": "auto_increment" } }, { @@ -665,7 +665,7 @@ "nullable": false, "description": "Playlist primary key identifier", "insertable": true, - "updatable": false, + "updatable": true, "value_generated": { "type": "auto_increment" } }, { @@ -707,7 +707,7 @@ "nullable": false, "description": "The ID of the playlist", "insertable": true, - "updatable": false + "updatable": true }, { "name": "TrackId", @@ -715,7 +715,7 @@ "nullable": false, "description": "The ID of the track", "insertable": true, - "updatable": false + "updatable": true } ], "insertable": true,