tthr 0.0.38 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -266,42 +266,15 @@ function parseSchema(source) {
|
|
|
266
266
|
const colName = colMatch[1];
|
|
267
267
|
const colType = colMatch[2];
|
|
268
268
|
const modifiers = colMatch[3];
|
|
269
|
-
if (colName === "_id" || colName === "_createdAt") {
|
|
270
|
-
console.warn(`Warning: Column '${colName}' is a reserved system column and will be ignored.`);
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
const userWantsPrimaryKey = modifiers.includes(".primaryKey()");
|
|
274
|
-
if (userWantsPrimaryKey) {
|
|
275
|
-
console.warn(`Warning: Column '${colName}' has .primaryKey() which will be ignored. Tether uses '_id' as the primary key.`);
|
|
276
|
-
}
|
|
277
269
|
columns[colName] = {
|
|
278
270
|
type: colType,
|
|
279
|
-
primaryKey:
|
|
280
|
-
// _id is always the primary key, ignore user-defined primary keys
|
|
271
|
+
primaryKey: modifiers.includes(".primaryKey()"),
|
|
281
272
|
notNull: modifiers.includes(".notNull()"),
|
|
282
|
-
unique: modifiers.includes(".unique()")
|
|
283
|
-
// Make it unique if they wanted PK
|
|
273
|
+
unique: modifiers.includes(".unique()"),
|
|
284
274
|
hasDefault: modifiers.includes(".default("),
|
|
285
275
|
references: modifiers.match(/\.references\s*\(\s*['"]([^'"]+)['"]\s*\)/)?.[1]
|
|
286
276
|
};
|
|
287
277
|
}
|
|
288
|
-
columns["_id"] = {
|
|
289
|
-
type: "text",
|
|
290
|
-
primaryKey: true,
|
|
291
|
-
notNull: true,
|
|
292
|
-
unique: true,
|
|
293
|
-
// Also set unique so ALTER TABLE adds UNIQUE constraint
|
|
294
|
-
hasDefault: false,
|
|
295
|
-
isSystemColumn: true
|
|
296
|
-
};
|
|
297
|
-
columns["_createdAt"] = {
|
|
298
|
-
type: "timestamp",
|
|
299
|
-
primaryKey: false,
|
|
300
|
-
notNull: true,
|
|
301
|
-
unique: false,
|
|
302
|
-
hasDefault: true,
|
|
303
|
-
isSystemColumn: true
|
|
304
|
-
};
|
|
305
278
|
tables.push({ name: tableName, columns, source: tableSource });
|
|
306
279
|
}
|
|
307
280
|
return tables;
|