@fxjs/orm
Advanced tools
Comparing version 1.16.3 to 1.16.4-alpha.0
const util = require("util"); | ||
const Utilities = require("./Utilities"); | ||
const ChainInstance = require("./ChainInstance"); | ||
const _dml_helpers_1 = require("./Drivers/DML/_dml-helpers"); | ||
const MODEL_FUNCS = [ | ||
@@ -11,2 +12,3 @@ "hasOne", "hasMany", | ||
const merges = opts.merge = Utilities.combineMergeInfoToArray(opts.merge); | ||
const isMySQL = opts.driver.db.type === 'mysql'; | ||
const chainRunSync = function () { | ||
@@ -20,2 +22,3 @@ let conditions = util.omit(opts.conditions, Model.virtualProperties); | ||
const { tableConditions, topConditions } = Utilities.extractSelectTopConditions(conditions, vFields); | ||
const __pointTypeMapsTo = !isMySQL ? [] : _dml_helpers_1.pickPointTypeFields(opts.driver, Model.allProperties); | ||
foundItems = opts.driver.find(opts.only, opts.table, tableConditions, { | ||
@@ -40,2 +43,3 @@ limit: Utilities.coercePositiveInt(opts.limit, undefined), | ||
generateSqlSelect: opts.generateSqlSelect, | ||
__pointTypeMapsTo | ||
}); | ||
@@ -224,2 +228,3 @@ if (foundItems.length === 0) { | ||
exists: opts.exists, | ||
__pointTypeMapsTo: [], | ||
}); | ||
@@ -226,0 +231,0 @@ if (data.length === 0) { |
@@ -11,2 +11,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
const Utilities = require("../../Utilities"); | ||
const _dml_helpers_1 = require("./_dml-helpers"); | ||
exports.Driver = function (config, connection, opts) { | ||
@@ -95,2 +96,9 @@ this.dialect = 'mysql'; | ||
const { from_tuple, pure_table, alias } = Utilities.parseTableInputForSelect(table); | ||
const __pointTypeMapsTo = opts.__pointTypeMapsTo || []; | ||
_dml_helpers_1.filterFieldsOnFind({ | ||
dmlDriver: this, | ||
pointPropertiesMapsTo: __pointTypeMapsTo, | ||
}, { | ||
selectFields, | ||
}); | ||
const ctx = { | ||
@@ -118,3 +126,11 @@ table, | ||
utils.buildExistsToQuery.apply(this, [q, alias, opts.exists]); | ||
return this.execSimpleQuery(q.build(), cb); | ||
const results = this.execSimpleQuery(q.build(), cb); | ||
if (__pointTypeMapsTo.length > 0 && Array.isArray(results)) { | ||
results.forEach(item => { | ||
__pointTypeMapsTo.forEach(field => { | ||
item[field] = _dml_helpers_1.safeParseJson(item[field]); | ||
}); | ||
}); | ||
} | ||
return results; | ||
}; | ||
@@ -121,0 +137,0 @@ exports.Driver.prototype.count = function (table, conditions, opts, cb) { |
@@ -20,2 +20,3 @@ /// <reference lib="es2017" /> | ||
const _utils_1 = require("./Associations/_utils"); | ||
const _dml_helpers_1 = require("./Drivers/DML/_dml-helpers"); | ||
const AvailableHooks = [ | ||
@@ -252,2 +253,3 @@ "beforeCreate", "afterCreate", | ||
}; | ||
const isMySQL = m_opts.driver.db.type === 'mysql'; | ||
model.getSync = function (...args) { | ||
@@ -279,2 +281,3 @@ if (!keyProperties.length) { | ||
const { tableConditions, topConditions } = Utilities.extractSelectTopConditions(conditions, vFields); | ||
const __pointTypeMapsTo = !isMySQL ? [] : _dml_helpers_1.pickPointTypeFields(m_opts.driver, allProperties); | ||
try { | ||
@@ -286,2 +289,3 @@ founditems = m_opts.driver.find(model_selectable_fields, m_opts.table, tableConditions, { | ||
generateSqlSelect: m_opts.generateSqlSelect, | ||
__pointTypeMapsTo, | ||
}); | ||
@@ -288,0 +292,0 @@ } |
{ | ||
"name": "@fxjs/orm", | ||
"version": "1.16.3", | ||
"version": "1.16.4-alpha.0", | ||
"description": "", | ||
@@ -37,7 +37,7 @@ "main": "lib", | ||
"@fibjs/enforce": "^0.1.1", | ||
"@fxjs/db-driver": "^0.5.0", | ||
"@fxjs/db-driver": "^0.5.1-alpha.0", | ||
"@fxjs/knex": "^0.4.1", | ||
"@fxjs/orm-core": "^0.3.2", | ||
"@fxjs/orm-property": "^0.4.0", | ||
"@fxjs/sql-ddl-sync": "^0.11.2", | ||
"@fxjs/orm-property": "^0.4.1-alpha.0", | ||
"@fxjs/sql-ddl-sync": "^0.11.3-alpha.0", | ||
"@fxjs/sql-query": "^0.10.0", | ||
@@ -78,3 +78,3 @@ "@types/knex": "^0.16.1", | ||
}, | ||
"gitHead": "aae7b161f1960c13f5455ba0e8d4112e5c7377c6" | ||
"gitHead": "1100c3d4a54a46d59d7c191d9d593c0ea640ac3b" | ||
} |
@@ -142,2 +142,4 @@ /// <reference types="@fibjs/types" /> | ||
generateSqlSelect?: (this: DMLDriver, ctx: __DMLDriver_FindSqlQueryModifierCtx, chainSelect: FxSqlQueryChainBuilder.ChainBuilder__Select) => typeof chainSelect | void; | ||
/** @experimental */ | ||
__pointTypeMapsTo: string[]; | ||
} | ||
@@ -144,0 +146,0 @@ export interface DMLDriver_CountOptions { |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
433965
107
9222
1