@pgtyped/query
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2
@@ -13,5 +13,22 @@ "use strict"; | ||
exports.PreparedQuery = exports.TaggedQuery = void 0; | ||
const typescript_1 = require("./loader/typescript"); | ||
const preprocessor_sql_1 = require("./preprocessor-sql"); | ||
const preprocessor_ts_1 = require("./preprocessor-ts"); | ||
const preprocessor_sql_1 = require("./preprocessor-sql"); | ||
const typescript_1 = require("./loader/typescript"); | ||
/** Check for column modifier suffixes (exclamation and question marks). */ | ||
function isHintedColumn(columnName) { | ||
const lastCharacter = columnName[columnName.length - 1]; | ||
return lastCharacter === '!' || lastCharacter === '?'; | ||
} | ||
function mapQueryResultRows(rows) { | ||
for (const row of rows) { | ||
for (const columnName in row) { | ||
if (isHintedColumn(columnName)) { | ||
const newColumnNameWithoutSuffix = columnName.slice(0, -1); | ||
row[newColumnNameWithoutSuffix] = row[columnName]; | ||
delete row[columnName]; | ||
} | ||
} | ||
} | ||
return rows; | ||
} | ||
/* Used for SQL-in-TS */ | ||
@@ -24,3 +41,3 @@ class TaggedQuery { | ||
const result = yield connection.query(processedQuery, bindings); | ||
return result.rows; | ||
return mapQueryResultRows(result.rows); | ||
}); | ||
@@ -41,3 +58,3 @@ } | ||
const result = yield connection.query(processedQuery, bindings); | ||
return result.rows; | ||
return mapQueryResultRows(result.rows); | ||
}); | ||
@@ -44,0 +61,0 @@ } |
{ | ||
"name": "@pgtyped/query", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0-alpha.2", | ||
"main": "lib/index.js", | ||
@@ -28,3 +28,3 @@ "types": "lib/index.d.ts", | ||
"dependencies": { | ||
"@pgtyped/wire": "^1.0.0-alpha.1", | ||
"@pgtyped/wire": "^1.0.0-alpha.2", | ||
"@types/chalk": "^2.2.0", | ||
@@ -42,3 +42,3 @@ "@types/debug": "^4.1.4", | ||
}, | ||
"gitHead": "d790e9f04f0335fa0f836a7a909b5b4814f98dc0" | ||
"gitHead": "44d1fa82638fa6d96dbd0f58b221d26a9d2fbd6f" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
345659
5933
Updated@pgtyped/wire@^1.0.0-alpha.2