remult
Advanced tools
Comparing version 0.25.7-exp.0 to 0.25.7-exp.1
@@ -83,2 +83,5 @@ import pg from 'pg'; | ||
addParameterAndReturnSqlToken(val) { | ||
return this.param(val); | ||
} | ||
param(val) { | ||
if (Array.isArray(val)) | ||
@@ -85,0 +88,0 @@ val = JSON.stringify(val); |
@@ -68,5 +68,5 @@ import { dbNamesOf, shouldNotCreateField, } from '../src/filter/filter-consumer-bridge-to-sql-request.js'; | ||
if (schema) { | ||
where.push(`table_schema=${cmd.addParameterAndReturnSqlToken(this.removeQuotes(schema))}`); | ||
where.push(`table_schema=${cmd.param(this.removeQuotes(schema))}`); | ||
} | ||
where.push(`table_name=${cmd.addParameterAndReturnSqlToken(this.removeQuotes(table))}`); | ||
where.push(`table_name=${cmd.param(this.removeQuotes(table))}`); | ||
return where.join(' AND '); | ||
@@ -166,3 +166,3 @@ } | ||
`${this.whereTableAndSchema(cmd, e)} ` + | ||
`AND column_name=${cmd.addParameterAndReturnSqlToken(colName.toLocaleLowerCase())}`)).rows.length == 0) { | ||
`AND column_name=${cmd.param(colName.toLocaleLowerCase())}`)).rows.length == 0) { | ||
let sql = `ALTER table ${this.schemaAndName(e)} ` + | ||
@@ -169,0 +169,0 @@ `ADD column ${postgresColumnSyntax(c(entity), colName)}`; |
@@ -95,2 +95,5 @@ import { SqlDatabase } from './src/data-providers/sql-database.js'; | ||
addParameterAndReturnSqlToken(val) { | ||
return this.param(val); | ||
} | ||
param(val) { | ||
if (val instanceof Date) | ||
@@ -97,0 +100,0 @@ val = val.valueOf(); |
@@ -61,3 +61,6 @@ import { CompoundIdField } from '../CompoundIdField.js'; | ||
return { | ||
addParameterAndReturnSqlToken: (x) => c.addParameterAndReturnSqlToken(x), | ||
addParameterAndReturnSqlToken: (val) => { | ||
return c.param(val); | ||
}, | ||
param: (x) => c.param(x), | ||
execute: async (sql) => { | ||
@@ -143,3 +146,6 @@ if (completed) | ||
addParameterAndReturnSqlToken(val) { | ||
let r = this.origin.addParameterAndReturnSqlToken(val); | ||
return this.param(val); | ||
} | ||
param(val, name) { | ||
let r = this.origin.param(val); | ||
this.args[r] = val; | ||
@@ -326,4 +332,3 @@ return r; | ||
statement += ', '; | ||
statement += | ||
e.$dbNameOf(x) + ' = ' + r.addParameterAndReturnSqlToken(v); | ||
statement += e.$dbNameOf(x) + ' = ' + r.param(v); | ||
} | ||
@@ -370,3 +375,3 @@ } | ||
cols += e.$dbNameOf(x); | ||
vals += r.addParameterAndReturnSqlToken(v); | ||
vals += r.param(v); | ||
} | ||
@@ -389,2 +394,5 @@ } | ||
addParameterAndReturnSqlToken(val) { | ||
return this.param(val); | ||
} | ||
param(val) { | ||
if (val === null) | ||
@@ -418,3 +426,3 @@ return 'null'; | ||
row.$.toArray() | ||
.map((f) => c.addParameterAndReturnSqlToken(f.metadata.valueConverter.toDb(f.value))) | ||
.map((f) => c.param(f.metadata.valueConverter.toDb(f.value))) | ||
.join(', ') + | ||
@@ -421,0 +429,0 @@ ')') |
@@ -104,2 +104,5 @@ import { dbNamesOf, isDbReadonly, } from '../filter/filter-consumer-bridge-to-sql-request.js'; | ||
addParameterAndReturnSqlToken(val) { | ||
return this.param(val); | ||
} | ||
param(val) { | ||
this.values.push(val); | ||
@@ -106,0 +109,0 @@ return '~' + this.values.length + '~'; |
@@ -64,3 +64,3 @@ import { SqlDatabase } from '../data-providers/sql-database.js'; | ||
val | ||
.map((x) => this.r.addParameterAndReturnSqlToken(col.valueConverter.toDb(x))) | ||
.map((x) => this.r.param(col.valueConverter.toDb(x))) | ||
.join(',') + | ||
@@ -114,3 +114,3 @@ ')'); | ||
' ' + | ||
this.r.addParameterAndReturnSqlToken(col.valueConverter.toDb(val)); | ||
this.r.param(col.valueConverter.toDb(val)); | ||
this.addToWhere(x); | ||
@@ -146,6 +146,11 @@ })()); | ||
sql = ''; | ||
addParameterAndReturnSqlToken(val, field) { | ||
if (field) | ||
/** @deprecated @deprecated use `param` instead*/ | ||
addParameterAndReturnSqlToken(val) { | ||
return this.param(val); | ||
} | ||
param(val, field) { | ||
if (typeof field === 'object' && field.valueConverter.toDb) { | ||
val = field.valueConverter.toDb(val); | ||
return this.r.addParameterAndReturnSqlToken(val); | ||
} | ||
return this.r.param(val); | ||
} | ||
@@ -152,0 +157,0 @@ async filterToRaw(repo, condition) { |
@@ -13,6 +13,8 @@ export {}; | ||
//y1 - getFields didn't work for kobi in the home component | ||
//p1 - JYC - change name of add parameter and .... to token - param | ||
//p1 - Hint names for sql parameters | ||
//p1 - add section to Fields doc, explaining field type in db | ||
/*p1 - JYC - Delete many, update many, insert many | ||
//p1 - @jycouet regarding required - are you ok with leaving '' as not a good value? (0 will be a good value) | ||
- post + __action=delet | ||
@@ -26,2 +28,19 @@ */ | ||
*/ | ||
/*y1 currency.ts:10 Uncaught TypeError: Currency_1 is not a constructor | ||
@ValueListFieldType() | ||
export class Currency { | ||
constructor( | ||
public id: number, | ||
public caption: string, | ||
public symbol: string | ||
) {} | ||
static shekel = new Currency(1, 'Shekel', '₪'); | ||
static dollar = new Currency(2, 'Dollar', '$'); | ||
static euro = new Currency(3, 'Euro', '€'); | ||
static pound = new Currency(4, 'Pound', '£'); | ||
static yen = new Currency(5, 'Yen', '¥'); | ||
} | ||
*/ | ||
//y1 - admin url! | ||
@@ -36,3 +55,4 @@ //y1 - consider sql expression gets a dbnames of it's own (that already has the "tableName" defined correctly) maybe also the filter translator | ||
//y1 - migrations | ||
//y2 - live query refresh of view on table update | ||
//y1 - live query refresh of view on table update | ||
//y1 - main vs master | ||
//y2 - livequery for findfirst (@JY) | ||
@@ -39,0 +59,0 @@ /*y2 - |
export class Validators { | ||
static required = createValidator(async (_, e) => e.value != null && e.value != undefined && e.value !== '' && e.value != 0, 'Should not be empty'); | ||
static required = createValidator(async (_, e) => e.value != null && e.value != undefined && e.value !== '', 'Should not be empty'); | ||
static unique = createValidator(async (_, e) => { | ||
@@ -4,0 +4,0 @@ if (!e.entityRef) |
{ | ||
"name": "remult", | ||
"version": "0.25.7-exp.0", | ||
"version": "0.25.7-exp.1", | ||
"description": "A CRUD framework for full-stack TypeScript", | ||
@@ -5,0 +5,0 @@ "homepage": "https://remult.dev", |
@@ -126,2 +126,5 @@ "use strict"; | ||
PostgresBridgeToSQLCommand.prototype.addParameterAndReturnSqlToken = function (val) { | ||
return this.param(val); | ||
}; | ||
PostgresBridgeToSQLCommand.prototype.param = function (val) { | ||
if (Array.isArray(val)) | ||
@@ -128,0 +131,0 @@ val = JSON.stringify(val); |
@@ -85,5 +85,5 @@ "use strict"; | ||
if (schema) { | ||
where.push("table_schema=".concat(cmd.addParameterAndReturnSqlToken(this.removeQuotes(schema)))); | ||
where.push("table_schema=".concat(cmd.param(this.removeQuotes(schema)))); | ||
} | ||
where.push("table_name=".concat(cmd.addParameterAndReturnSqlToken(this.removeQuotes(table)))); | ||
where.push("table_name=".concat(cmd.param(this.removeQuotes(table)))); | ||
return where.join(' AND '); | ||
@@ -294,3 +294,3 @@ }; | ||
"".concat(this.whereTableAndSchema(cmd, e), " ") + | ||
"AND column_name=".concat(cmd.addParameterAndReturnSqlToken(colName.toLocaleLowerCase())))]; | ||
"AND column_name=".concat(cmd.param(colName.toLocaleLowerCase())))]; | ||
case 3: | ||
@@ -297,0 +297,0 @@ if (!((_a.sent()).rows.length == 0)) return [3 /*break*/, 5]; |
@@ -186,2 +186,5 @@ "use strict"; | ||
SqlJsCommand.prototype.addParameterAndReturnSqlToken = function (val) { | ||
return this.param(val); | ||
}; | ||
SqlJsCommand.prototype.param = function (val) { | ||
if (val instanceof Date) | ||
@@ -188,0 +191,0 @@ val = val.valueOf(); |
@@ -112,5 +112,6 @@ "use strict"; | ||
return { | ||
addParameterAndReturnSqlToken: function (x) { | ||
return c.addParameterAndReturnSqlToken(x); | ||
addParameterAndReturnSqlToken: function (val) { | ||
return c.param(val); | ||
}, | ||
param: function (x) { return c.param(x); }, | ||
execute: function (sql) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
@@ -221,3 +222,6 @@ return tslib_1.__generator(this, function (_a) { | ||
LogSQLCommand.prototype.addParameterAndReturnSqlToken = function (val) { | ||
var r = this.origin.addParameterAndReturnSqlToken(val); | ||
return this.param(val); | ||
}; | ||
LogSQLCommand.prototype.param = function (val, name) { | ||
var r = this.origin.param(val); | ||
this.args[r] = val; | ||
@@ -495,4 +499,3 @@ return r; | ||
statement += ', '; | ||
statement += | ||
e.$dbNameOf(x) + ' = ' + r.addParameterAndReturnSqlToken(v); | ||
statement += e.$dbNameOf(x) + ' = ' + r.param(v); | ||
} | ||
@@ -578,3 +581,3 @@ } | ||
cols += e.$dbNameOf(x); | ||
vals += r.addParameterAndReturnSqlToken(v); | ||
vals += r.param(v); | ||
} | ||
@@ -614,2 +617,5 @@ } | ||
myDummySQLCommand.prototype.addParameterAndReturnSqlToken = function (val) { | ||
return this.param(val); | ||
}; | ||
myDummySQLCommand.prototype.param = function (val) { | ||
if (val === null) | ||
@@ -659,5 +665,3 @@ return 'null'; | ||
row.$.toArray() | ||
.map(function (f) { | ||
return c.addParameterAndReturnSqlToken(f.metadata.valueConverter.toDb(f.value)); | ||
}) | ||
.map(function (f) { return c.param(f.metadata.valueConverter.toDb(f.value)); }) | ||
.join(', ') + | ||
@@ -664,0 +668,0 @@ ')'; |
@@ -185,2 +185,5 @@ "use strict"; | ||
WebSqlBridgeToSQLCommand.prototype.addParameterAndReturnSqlToken = function (val) { | ||
return this.param(val); | ||
}; | ||
WebSqlBridgeToSQLCommand.prototype.param = function (val) { | ||
this.values.push(val); | ||
@@ -187,0 +190,0 @@ return '~' + this.values.length + '~'; |
@@ -39,3 +39,5 @@ import type { FieldMetadata } from '../column-interfaces.js'; | ||
sql: string; | ||
addParameterAndReturnSqlToken<valueType>(val: valueType, field?: FieldMetadata<valueType>): string; | ||
/** @deprecated @deprecated use `param` instead*/ | ||
addParameterAndReturnSqlToken(val: any): string; | ||
param<valueType>(val: valueType, field?: FieldMetadata<valueType>): string; | ||
filterToRaw<entityType>(repo: RepositoryOverloads<entityType>, condition: EntityFilter<entityType>): Promise<string>; | ||
@@ -42,0 +44,0 @@ } |
@@ -138,5 +138,3 @@ "use strict"; | ||
val | ||
.map(function (x) { | ||
return _this.r.addParameterAndReturnSqlToken(col.valueConverter.toDb(x)); | ||
}) | ||
.map(function (x) { return _this.r.param(col.valueConverter.toDb(x)); }) | ||
.join(',') + | ||
@@ -203,3 +201,3 @@ ')'); | ||
' ' + | ||
this.r.addParameterAndReturnSqlToken(col.valueConverter.toDb(val)); | ||
this.r.param(col.valueConverter.toDb(val)); | ||
this.addToWhere(x); | ||
@@ -248,6 +246,11 @@ return [2 /*return*/]; | ||
} | ||
CustomSqlFilterBuilder.prototype.addParameterAndReturnSqlToken = function (val, field) { | ||
if (field) | ||
/** @deprecated @deprecated use `param` instead*/ | ||
CustomSqlFilterBuilder.prototype.addParameterAndReturnSqlToken = function (val) { | ||
return this.param(val); | ||
}; | ||
CustomSqlFilterBuilder.prototype.param = function (val, field) { | ||
if (typeof field === 'object' && field.valueConverter.toDb) { | ||
val = field.valueConverter.toDb(val); | ||
return this.r.addParameterAndReturnSqlToken(val); | ||
} | ||
return this.r.param(val); | ||
}; | ||
@@ -254,0 +257,0 @@ CustomSqlFilterBuilder.prototype.filterToRaw = function (repo, condition) { |
@@ -14,6 +14,8 @@ "use strict"; | ||
//y1 - getFields didn't work for kobi in the home component | ||
//p1 - JYC - change name of add parameter and .... to token - param | ||
//p1 - Hint names for sql parameters | ||
//p1 - add section to Fields doc, explaining field type in db | ||
/*p1 - JYC - Delete many, update many, insert many | ||
//p1 - @jycouet regarding required - are you ok with leaving '' as not a good value? (0 will be a good value) | ||
- post + __action=delet | ||
@@ -27,2 +29,19 @@ */ | ||
*/ | ||
/*y1 currency.ts:10 Uncaught TypeError: Currency_1 is not a constructor | ||
@ValueListFieldType() | ||
export class Currency { | ||
constructor( | ||
public id: number, | ||
public caption: string, | ||
public symbol: string | ||
) {} | ||
static shekel = new Currency(1, 'Shekel', '₪'); | ||
static dollar = new Currency(2, 'Dollar', '$'); | ||
static euro = new Currency(3, 'Euro', '€'); | ||
static pound = new Currency(4, 'Pound', '£'); | ||
static yen = new Currency(5, 'Yen', '¥'); | ||
} | ||
*/ | ||
//y1 - admin url! | ||
@@ -37,3 +56,4 @@ //y1 - consider sql expression gets a dbnames of it's own (that already has the "tableName" defined correctly) maybe also the filter translator | ||
//y1 - migrations | ||
//y2 - live query refresh of view on table update | ||
//y1 - live query refresh of view on table update | ||
//y1 - main vs master | ||
//y2 - livequery for findfirst (@JY) | ||
@@ -40,0 +60,0 @@ /*y2 - |
@@ -20,2 +20,6 @@ import type { ClassType } from '../../classType.js'; | ||
private defaultFindOptions?; | ||
notFoundError(id: any): { | ||
message: string; | ||
httpStatusCode: number; | ||
}; | ||
[getInternalKey](): this; | ||
@@ -22,0 +26,0 @@ createAfterFilter(orderBy: EntityOrderBy<entityType>, lastRow: entityType): Promise<EntityFilter<entityType>>; |
@@ -19,3 +19,5 @@ import type { EntityMetadata } from './remult3/remult3.js'; | ||
export interface SqlCommandWithParameters { | ||
/** @deprecated @deprecated use `param` instead*/ | ||
addParameterAndReturnSqlToken(val: any): string; | ||
param(val: any): string; | ||
} | ||
@@ -22,0 +24,0 @@ export interface SqlResult { |
@@ -11,3 +11,3 @@ "use strict"; | ||
Validators.required = createValidator(function (_, e) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { return tslib_1.__generator(_a, function (_b) { | ||
return [2 /*return*/, e.value != null && e.value != undefined && e.value !== '' && e.value != 0]; | ||
return [2 /*return*/, e.value != null && e.value != undefined && e.value !== '']; | ||
}); }); }, 'Should not be empty'); | ||
@@ -14,0 +14,0 @@ Validators.unique = createValidator(function (_, e) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
4819284
46944