@oino-ts/db-postgresql 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -320,7 +320,13 @@ WHERE col.table_catalog = '${dbName}' AND col.table_name = '${tableName}'`;
|
|
|
320
320
|
isNotNull: row[3] == "NO",
|
|
321
321
|
isAutoInc: default_val.startsWith("nextval(")
|
|
322
322
|
};
|
|
323
|
-
if (
|
|
323
|
+
if (api.isFieldIncluded(field_name) == false) {
|
|
324
|
+
db_1.OINOLog.info("OINODbPostgresql.initializeApiDatamodel: field excluded in API parameters.", { field: field_name });
|
|
325
|
+
if (field_params.isPrimaryKey) {
|
|
326
|
+
throw new Error(db_1.OINO_ERROR_PREFIX + "Primary key field excluded in API parameters: " + field_name);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
324
330
|
// OINOLog.debug("OINODbPostgresql.initializeApiDatamodel: next field ", {field_name: field_name, sql_type:sql_type, field_length:field_length, field_params:field_params })
|
|
325
331
|
if ((sql_type == "integer") || (sql_type == "smallint") || (sql_type == "real")) {
|
|
326
332
|
api.datamodel.addField(new db_1.OINONumberDataField(this, field_name, sql_type, field_params));
|
|
@@ -317,7 +317,13 @@ WHERE col.table_catalog = '${dbName}' AND col.table_name = '${tableName}'`;
|
|
|
317
317
|
isNotNull: row[3] == "NO",
|
|
318
318
|
isAutoInc: default_val.startsWith("nextval(")
|
|
319
319
|
};
|
|
320
|
-
if (
|
|
320
|
+
if (api.isFieldIncluded(field_name) == false) {
|
|
321
|
+
OINOLog.info("OINODbPostgresql.initializeApiDatamodel: field excluded in API parameters.", { field: field_name });
|
|
322
|
+
if (field_params.isPrimaryKey) {
|
|
323
|
+
throw new Error(OINO_ERROR_PREFIX + "Primary key field excluded in API parameters: " + field_name);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
321
327
|
// OINOLog.debug("OINODbPostgresql.initializeApiDatamodel: next field ", {field_name: field_name, sql_type:sql_type, field_length:field_length, field_params:field_params })
|
|
322
328
|
if ((sql_type == "integer") || (sql_type == "smallint") || (sql_type == "real")) {
|
|
323
329
|
api.datamodel.addField(new OINONumberDataField(this, field_name, sql_type, field_params));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/db-postgresql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "OINO TS package for using Postgresql databases.",
|
|
5
5
|
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"module": "./dist/esm/index.js",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@oino-ts/db": "0.
|
|
23
|
+
"@oino-ts/db": "0.3.0",
|
|
24
24
|
"pg": "^8.11.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
package/src/OINODbPostgresql.ts
CHANGED
|
@@ -339,7 +339,13 @@ WHERE col.table_catalog = '${dbName}' AND col.table_name = '${tableName}'`
|
|
|
339
339
|
isNotNull: row[3] == "NO",
|
|
340
340
|
isAutoInc: default_val.startsWith("nextval(")
|
|
341
341
|
}
|
|
342
|
-
if (
|
|
342
|
+
if (api.isFieldIncluded(field_name) == false) {
|
|
343
|
+
OINOLog.info("OINODbPostgresql.initializeApiDatamodel: field excluded in API parameters.", {field:field_name})
|
|
344
|
+
if (field_params.isPrimaryKey) {
|
|
345
|
+
throw new Error(OINO_ERROR_PREFIX + "Primary key field excluded in API parameters: " + field_name)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
} else {
|
|
343
349
|
// OINOLog.debug("OINODbPostgresql.initializeApiDatamodel: next field ", {field_name: field_name, sql_type:sql_type, field_length:field_length, field_params:field_params })
|
|
344
350
|
if ((sql_type == "integer") || (sql_type == "smallint") || (sql_type == "real")) {
|
|
345
351
|
api.datamodel.addField(new OINONumberDataField(this, field_name, sql_type, field_params ))
|
|
@@ -366,7 +372,7 @@ WHERE col.table_catalog = '${dbName}' AND col.table_name = '${tableName}'`
|
|
|
366
372
|
} else {
|
|
367
373
|
OINOLog.info("OINODbPostgresql.initializeApiDatamodel: unrecognized field type treated as string", {field_name: field_name, sql_type:sql_type, field_length:field_length, field_params:field_params })
|
|
368
374
|
api.datamodel.addField(new OINOStringDataField(this, field_name, sql_type, field_params, 0))
|
|
369
|
-
}
|
|
375
|
+
}
|
|
370
376
|
}
|
|
371
377
|
await res.next()
|
|
372
378
|
}
|