New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ibmi): add database version compatibility check for native boolean + initial unit tests #16909
base: main
Are you sure you want to change the base?
Changes from all commits
9fedae9
ca126e8
e364224
14c38a0
a551b9f
14d1629
4ebf2c3
f53e531
14e86a1
d821599
b360e8e
dec53c5
520ed09
fdebe0e
f2c2370
3f99bcb
a7c78b9
d33bb0f
05d8407
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,27 @@ export class UUID extends BaseTypes.UUID { | |
} | ||
|
||
export class BOOLEAN extends BaseTypes.BOOLEAN { | ||
protected supportsNativeBooleans() { | ||
const databaseVersion | ||
= Number.parseFloat(this._getDialect().sequelize.options.databaseVersion || this._getDialect().defaultVersion); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't get the database version like this, but via |
||
|
||
return databaseVersion >= 7.5; | ||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use the |
||
} | ||
|
||
escape(value: boolean | Falsy): string { | ||
return value ? '1' : '0'; | ||
return this.supportsNativeBooleans() ? super.escape(value) : value ? '1' : '0'; | ||
} | ||
|
||
parseDatabaseValue(value: unknown): boolean { | ||
return this.supportsNativeBooleans() ? value === 'TRUE' : value === 1; | ||
} | ||
|
||
toBindableValue(value: boolean | Falsy): unknown { | ||
return value ? 1 : 0; | ||
return this.supportsNativeBooleans() ? super.toBindableValue(value) : value ? 1 : 0; | ||
} | ||
|
||
toSql() { | ||
return 'SMALLINT'; | ||
return this.supportsNativeBooleans() ? super.toSql() : 'SMALLINT'; | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -335,7 +335,6 @@ export class IBMiQueryGenerator extends IBMiQueryGeneratorTypeScript { | |
const query = super.insertQuery(table, valueHash, modelAttributes, options); | ||
if (query.query.at(-1) === ';') { | ||
query.query = query.query.slice(0, -1); | ||
query.query = `SELECT * FROM FINAL TABLE (${query.query})`; | ||
} | ||
|
||
return query; | ||
|
@@ -356,7 +355,6 @@ export class IBMiQueryGenerator extends IBMiQueryGeneratorTypeScript { | |
let query = super.bulkInsertQuery(tableName, fieldValueHashes, options, fieldMappedAttributes); | ||
if (query.at(-1) === ';') { | ||
query = query.slice(0, -1); | ||
query = `SELECT * FROM FINAL TABLE (${query})`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why remove the "select from final table"? :o |
||
} | ||
|
||
return query; | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -96,5 +96,6 @@ export const Config: Record<Dialect, Options> = { | |||
dialectOptions: { | ||||
odbcConnectionString: env.SEQ_IBMI_CONN_STR, | ||||
}, | ||||
databaseVersion: '7.3.0', | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
ibmi has a defaultVersion of 7.3.0 already |
||||
}, | ||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be hard private