Skip to content

Commit 740b984

Browse files
Copilotmathiasrw
andcommitted
Add behavioral tests for FK/PK constraints and fix NULL/NaN handling
Co-authored-by: mathiasrw <[email protected]>
1 parent 63d24ac commit 740b984

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/60createtable.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
173173
};
174174
var fkfn = function (r) {
175175
var rr = {};
176-
if (typeof r[col.columnid] === 'undefined') {
176+
if (r[col.columnid] == null) {
177177
return true;
178178
}
179179
rr[fk.columnid] = r[col.columnid];
@@ -270,8 +270,10 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
270270

271271
//Composite foreign keys
272272
fk.fkcolumns.forEach(function (colFk, i) {
273-
if (r[fk.columns[i]] != null) {
274-
rr[colFk] = r[fk.columns[i]];
273+
var val = r[fk.columns[i]];
274+
// Only include non-null, non-undefined, non-NaN values
275+
if (val != null && !(typeof val === 'number' && isNaN(val))) {
276+
rr[colFk] = val;
275277
}
276278
});
277279

0 commit comments

Comments
 (0)