masterrecord 1.0.4 → 1.0.5
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/.claude/settings.local.json +2 -71
- package/Entity/entityModel.js +19 -0
- package/Migrations/migrationMySQLQuery.js +6 -0
- package/Migrations/migrationPostgresQuery.js +4 -0
- package/Migrations/migrationSQLiteQuery.js +16 -5
- package/package.json +1 -1
- package/test/fixtures/{multi-migration-GAf8bq → multi-migration-N4bUYy}/app/models/multimigctx.js +1 -1
- package/test/fixtures/{multi-migration-3Rsgm3 → multi-migration-N4bUYy}/config/environments/env.multimig.json +1 -1
- package/test/fixtures/{multi-migration-GAf8bq → multi-migration-N4bUYy}/db/multimigctx.sqlite +0 -0
- package/test/fixtures/{multi-migration-QZg3WH → multi-migration-Qu42ZE}/app/models/multimigctx.js +1 -1
- package/test/fixtures/{multi-migration-GAf8bq → multi-migration-Qu42ZE}/config/environments/env.multimig.json +1 -1
- package/test/fixtures/{multi-migration-QZg3WH → multi-migration-Qu42ZE}/db/multimigctx.sqlite +0 -0
- package/test/fixtures/{multi-migration-3Rsgm3 → multi-migration-xDfXbJ}/app/models/multimigctx.js +1 -1
- package/test/fixtures/{multi-migration-QZg3WH → multi-migration-xDfXbJ}/config/environments/env.multimig.json +1 -1
- package/test/fixtures/{multi-migration-3Rsgm3 → multi-migration-xDfXbJ}/db/multimigctx.sqlite +0 -0
- package/test/fixtures/text-types/config/environments/env.texttypes.json +1 -0
- package/test/fixtures/text-types/db/textctx.sqlite +0 -0
- package/test/text-types.test.js +167 -0
- /package/test/fixtures/{multi-migration-3Rsgm3 → multi-migration-N4bUYy}/app/models/db/migrations/1700000001000_CreateAuthor_migration.js +0 -0
- /package/test/fixtures/{multi-migration-3Rsgm3 → multi-migration-N4bUYy}/app/models/db/migrations/1700000002000_CreateBook_migration.js +0 -0
- /package/test/fixtures/{multi-migration-3Rsgm3 → multi-migration-N4bUYy}/app/models/db/migrations/1700000003000_CreateReview_migration.js +0 -0
- /package/test/fixtures/{multi-migration-GAf8bq → multi-migration-N4bUYy}/app/models/db/migrations/multimigctx_contextSnapShot.json +0 -0
- /package/test/fixtures/{multi-migration-3Rsgm3 → multi-migration-N4bUYy}/package.json +0 -0
- /package/test/fixtures/{multi-migration-GAf8bq → multi-migration-Qu42ZE}/app/models/db/migrations/1700000001000_CreateAuthor_migration.js +0 -0
- /package/test/fixtures/{multi-migration-GAf8bq → multi-migration-Qu42ZE}/app/models/db/migrations/1700000002000_CreateBook_migration.js +0 -0
- /package/test/fixtures/{multi-migration-GAf8bq → multi-migration-Qu42ZE}/app/models/db/migrations/1700000003000_CreateReview_migration.js +0 -0
- /package/test/fixtures/{multi-migration-QZg3WH → multi-migration-Qu42ZE}/app/models/db/migrations/multimigctx_contextSnapShot.json +0 -0
- /package/test/fixtures/{multi-migration-GAf8bq → multi-migration-Qu42ZE}/package.json +0 -0
- /package/test/fixtures/{multi-migration-QZg3WH → multi-migration-xDfXbJ}/app/models/db/migrations/1700000001000_CreateAuthor_migration.js +0 -0
- /package/test/fixtures/{multi-migration-QZg3WH → multi-migration-xDfXbJ}/app/models/db/migrations/1700000002000_CreateBook_migration.js +0 -0
- /package/test/fixtures/{multi-migration-QZg3WH → multi-migration-xDfXbJ}/app/models/db/migrations/1700000003000_CreateReview_migration.js +0 -0
- /package/test/fixtures/{multi-migration-3Rsgm3 → multi-migration-xDfXbJ}/app/models/db/migrations/multimigctx_contextSnapShot.json +0 -0
- /package/test/fixtures/{multi-migration-QZg3WH → multi-migration-xDfXbJ}/package.json +0 -0
|
@@ -1,76 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"permissions": {
|
|
3
3
|
"allow": [
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"Read(//Users/alexanderrich/Documents/development/bookbaghq/bookbag-ce/config/environments/**)",
|
|
7
|
-
"Bash(node test/tablePrefixTest.js:*)",
|
|
8
|
-
"Bash(node test/whereChainingTest.js:*)",
|
|
9
|
-
"Bash(npm whoami:*)",
|
|
10
|
-
"Bash(npm pkg fix:*)",
|
|
11
|
-
"Bash(~/.npmrc)",
|
|
12
|
-
"Bash(cat:*)",
|
|
13
|
-
"Bash(node test/includesTransformTest.js:*)",
|
|
14
|
-
"Bash(node test/securityTest.js:*)",
|
|
15
|
-
"Bash(node test/transformerTest.js:*)",
|
|
16
|
-
"Bash(node:*)",
|
|
17
|
-
"Bash(npm publish)",
|
|
18
|
-
"Bash(npm owner:*)",
|
|
19
|
-
"Bash(npm profile get:*)",
|
|
20
|
-
"Bash(npm cache clean:*)",
|
|
21
|
-
"Bash(npm config:*)",
|
|
22
|
-
"Bash(npm publish:*)",
|
|
23
|
-
"Bash(npm logout)",
|
|
24
|
-
"Bash(npm access:*)",
|
|
25
|
-
"Bash(npm view:*)",
|
|
26
|
-
"Bash(git add:*)",
|
|
27
|
-
"Bash(git commit:*)",
|
|
28
|
-
"Bash(git push)",
|
|
29
|
-
"Bash(find:*)",
|
|
30
|
-
"Bash(npm install)",
|
|
31
|
-
"Bash(ls:*)",
|
|
32
|
-
"Bash(grep:*)",
|
|
33
|
-
"Bash(npm audit:*)",
|
|
34
|
-
"Bash(npm test:*)",
|
|
35
|
-
"Bash(done)",
|
|
36
|
-
"WebSearch",
|
|
37
|
-
"WebFetch(domain:github.com)",
|
|
38
|
-
"Bash(master=development masterrecord update-database qaContext)",
|
|
39
|
-
"Bash(chmod:*)",
|
|
40
|
-
"Bash(npm install:*)",
|
|
41
|
-
"Bash(sqlite3:*)",
|
|
42
|
-
"Bash(for file in /Users/alexanderrich/Documents/development/bookbaghq/bookbag-training/components/models/app/controllers/api/*.js)",
|
|
43
|
-
"Bash(do)",
|
|
44
|
-
"Bash(if grep -q \"this._currentUser = req.authService.currentUser\" \"$file\")",
|
|
45
|
-
"Bash(then)",
|
|
46
|
-
"Bash(fi)",
|
|
47
|
-
"Bash(echo:*)",
|
|
48
|
-
"Bash(/tmp/fix_controllers.sh)",
|
|
49
|
-
"Bash(wc -l echo \"\" echo \"Controllers now using async pattern:\" find /Users/alexanderrich/Documents/development/bookbaghq/bookbag-training/components -name \"*Controller.js\" -path \"*/controllers/api/*\" -exec grep -l \"async _getCurrentUser\\(\\)\" {})",
|
|
50
|
-
"Bash(/tmp/fix_controllers.sh:*)",
|
|
51
|
-
"Bash(wc -l echo \"\" echo \"Total with async _getCurrentUser\\(\\):\" find /Users/alexanderrich/Documents/development/bookbaghq/bookbag-training/components -name \"*Controller.js\" -path \"*/controllers/api/*\" -exec grep -l \"async _getCurrentUser\\(\\)\" {})",
|
|
52
|
-
"Bash(wc -l echo echo 'Controllers with async _getCurrentUser\\(\\):' find /Users/alexanderrich/Documents/development/bookbaghq/bookbag-training/components -name *Controller.js -path */controllers/* -exec grep -l 'async _getCurrentUser\\(\\)' {})",
|
|
53
|
-
"Bash(sort -u __NEW_LINE_463d116b631aaffc__ echo 'Actual controller files \\(without .js extension\\):' find /Users/alexanderrich/Documents/development/bookbaghq/bookbag-training/components/*/app/controllers/api -name *.js -type f)",
|
|
54
|
-
"Bash(xargs:*)",
|
|
55
|
-
"Bash(sort -u __NEW_LINE_463d116b631aaffc__ echo echo 'Files that exist but not referenced in routes \\(might be OK\\):' comm -13 /tmp/route_refs.txt /tmp/actual_files.txt)",
|
|
56
|
-
"Bash(head -10 __NEW_LINE_463d116b631aaffc__ echo \"\" echo \"Routes referencing non-existent files \\(PROBLEMS\\):\" comm -23 /tmp/route_refs.txt /tmp/actual_files.txt)",
|
|
57
|
-
"Bash(for file in /Users/alexanderrich/Documents/development/bookbaghq/bookbag-training/components/qa/app/controllers/api/*.js)",
|
|
58
|
-
"Bash(wc:*)",
|
|
59
|
-
"Bash(npm link)",
|
|
60
|
-
"Bash(npm link:*)",
|
|
61
|
-
"Bash(1)",
|
|
62
|
-
"Bash(masterrecord update-database:*)",
|
|
63
|
-
"Bash(npx mocha:*)",
|
|
64
|
-
"Bash(masterrecord add-migration:*)",
|
|
65
|
-
"Bash(masterrecord:*)",
|
|
66
|
-
"Bash(git -C /Users/alexanderrich/Documents/development/bookbaghq/bookbag-training log --oneline --all -- *MASTERRECORD_ISSUE*)",
|
|
67
|
-
"Bash(npm ls -g masterrecord 2>&1 | head -5)",
|
|
68
|
-
"Bash(gh pr:*)",
|
|
69
|
-
"Read(//tmp/**)",
|
|
70
|
-
"Bash(wait)",
|
|
71
|
-
"Bash(pkill -f \"node --test\")"
|
|
72
|
-
],
|
|
73
|
-
"deny": [],
|
|
74
|
-
"ask": []
|
|
4
|
+
"Bash(node --test --test-timeout=20000 test/text-types.test.js)"
|
|
5
|
+
]
|
|
75
6
|
}
|
|
76
7
|
}
|
package/Entity/entityModel.js
CHANGED
|
@@ -64,6 +64,25 @@ class EntityModel {
|
|
|
64
64
|
return this;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Medium-length text. On MySQL emits `MEDIUMTEXT` (up to ~16 MB).
|
|
69
|
+
* On SQLite and PostgreSQL collapses to `TEXT` (already unlimited there),
|
|
70
|
+
* so the same entity definition works portably across engines.
|
|
71
|
+
*/
|
|
72
|
+
mediumtext(){
|
|
73
|
+
this.obj.type = "mediumtext";
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Long-form text. On MySQL emits `LONGTEXT` (up to ~4 GB).
|
|
79
|
+
* On SQLite and PostgreSQL collapses to `TEXT` (already unlimited there).
|
|
80
|
+
*/
|
|
81
|
+
longtext(){
|
|
82
|
+
this.obj.type = "longtext";
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
|
|
67
86
|
integer(){
|
|
68
87
|
this.obj.type = "integer";
|
|
69
88
|
return this;
|
|
@@ -85,6 +85,10 @@ class migrationPostgresQuery {
|
|
|
85
85
|
case "string":
|
|
86
86
|
return "VARCHAR(255)"
|
|
87
87
|
case "text":
|
|
88
|
+
case "mediumtext":
|
|
89
|
+
case "longtext":
|
|
90
|
+
// PostgreSQL TEXT is unlimited — MySQL's MEDIUMTEXT/LONGTEXT
|
|
91
|
+
// sizing has no analogue here; collapse to TEXT for portability.
|
|
88
92
|
return "TEXT"
|
|
89
93
|
case "float":
|
|
90
94
|
return "REAL" // PostgreSQL uses REAL for single-precision
|
|
@@ -72,18 +72,29 @@ class migrationSQLiteQuery {
|
|
|
72
72
|
case "string":
|
|
73
73
|
return "TEXT"
|
|
74
74
|
break;
|
|
75
|
+
case "text":
|
|
76
|
+
case "mediumtext":
|
|
77
|
+
case "longtext":
|
|
78
|
+
// SQLite TEXT is unlimited — MEDIUMTEXT/LONGTEXT collapse to TEXT
|
|
79
|
+
// for cross-engine portability. (Previously "text" had no case
|
|
80
|
+
// here at all, which produced "<colname> undefined NOT NULL"
|
|
81
|
+
// SQL — accepted by SQLite's lax type affinity but still wrong.)
|
|
82
|
+
return "TEXT"
|
|
83
|
+
break;
|
|
75
84
|
case "time":
|
|
76
85
|
return "TEXT"
|
|
77
86
|
break;
|
|
78
|
-
|
|
87
|
+
case "boolean":
|
|
79
88
|
return "INTEGER"
|
|
80
89
|
break;
|
|
81
|
-
|
|
90
|
+
case "integer":
|
|
82
91
|
return "INTEGER"
|
|
83
92
|
break;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
93
|
+
default:
|
|
94
|
+
// Fallback for unknown types so we never emit `undefined`.
|
|
95
|
+
return "TEXT"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
87
98
|
|
|
88
99
|
alterColumn(fullTable, table){
|
|
89
100
|
if(table){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "masterrecord",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.005",
|
|
4
4
|
"description": "An Object-relational mapping for the Master framework. Master Record connects classes to relational database tables to establish a database with almost zero-configuration ",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./MasterRecord.js",
|
package/test/fixtures/{multi-migration-GAf8bq → multi-migration-N4bUYy}/app/models/multimigctx.js
RENAMED
|
@@ -17,7 +17,7 @@ class Review {
|
|
|
17
17
|
class multimigctx extends context {
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
20
|
-
this.env("/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-
|
|
20
|
+
this.env("/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-N4bUYy/config/environments");
|
|
21
21
|
this.dbset(Author);
|
|
22
22
|
this.dbset(Book);
|
|
23
23
|
this.dbset(Review);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"multimigctx":{"type":"better-sqlite3","connection":"/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-
|
|
1
|
+
{"multimigctx":{"type":"better-sqlite3","connection":"/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-N4bUYy/db/"}}
|
package/test/fixtures/{multi-migration-GAf8bq → multi-migration-N4bUYy}/db/multimigctx.sqlite
RENAMED
|
Binary file
|
package/test/fixtures/{multi-migration-QZg3WH → multi-migration-Qu42ZE}/app/models/multimigctx.js
RENAMED
|
@@ -17,7 +17,7 @@ class Review {
|
|
|
17
17
|
class multimigctx extends context {
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
20
|
-
this.env("/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-
|
|
20
|
+
this.env("/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-Qu42ZE/config/environments");
|
|
21
21
|
this.dbset(Author);
|
|
22
22
|
this.dbset(Book);
|
|
23
23
|
this.dbset(Review);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"multimigctx":{"type":"better-sqlite3","connection":"/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-
|
|
1
|
+
{"multimigctx":{"type":"better-sqlite3","connection":"/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-Qu42ZE/db/"}}
|
package/test/fixtures/{multi-migration-QZg3WH → multi-migration-Qu42ZE}/db/multimigctx.sqlite
RENAMED
|
Binary file
|
package/test/fixtures/{multi-migration-3Rsgm3 → multi-migration-xDfXbJ}/app/models/multimigctx.js
RENAMED
|
@@ -17,7 +17,7 @@ class Review {
|
|
|
17
17
|
class multimigctx extends context {
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
20
|
-
this.env("/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-
|
|
20
|
+
this.env("/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-xDfXbJ/config/environments");
|
|
21
21
|
this.dbset(Author);
|
|
22
22
|
this.dbset(Book);
|
|
23
23
|
this.dbset(Review);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"multimigctx":{"type":"better-sqlite3","connection":"/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-
|
|
1
|
+
{"multimigctx":{"type":"better-sqlite3","connection":"/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/multi-migration-xDfXbJ/db/"}}
|
package/test/fixtures/{multi-migration-3Rsgm3 → multi-migration-xDfXbJ}/db/multimigctx.sqlite
RENAMED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"TextCtx":{"type":"better-sqlite3","connection":"/Users/alexanderrich/Documents/development/opensourceHQ/MasterRecord/test/fixtures/text-types/db/"}}
|
|
File without changes
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies db.text() / db.mediumtext() / db.longtext() emit correct
|
|
3
|
+
* column types on each engine.
|
|
4
|
+
*
|
|
5
|
+
* MySQL → TEXT, MEDIUMTEXT, LONGTEXT
|
|
6
|
+
* SQLite → TEXT, TEXT, TEXT (SQLite TEXT is unlimited)
|
|
7
|
+
* Postgres → TEXT, TEXT, TEXT (Postgres TEXT is unlimited)
|
|
8
|
+
*
|
|
9
|
+
* Also catches the prior bug where SQLite's #typeManager had no `text` case
|
|
10
|
+
* and emitted "<colname> undefined NOT NULL" — accepted by SQLite's lax type
|
|
11
|
+
* affinity but still wrong.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { test } from 'node:test';
|
|
15
|
+
import assert from 'node:assert/strict';
|
|
16
|
+
import fs from 'node:fs';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import { fileURLToPath } from 'node:url';
|
|
19
|
+
|
|
20
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
const fixturesDir = path.join(__dirname, 'fixtures', 'text-types');
|
|
22
|
+
const envDir = path.join(fixturesDir, 'config', 'environments');
|
|
23
|
+
const dbDir = path.join(fixturesDir, 'db');
|
|
24
|
+
|
|
25
|
+
fs.mkdirSync(envDir, { recursive: true });
|
|
26
|
+
fs.mkdirSync(dbDir, { recursive: true });
|
|
27
|
+
|
|
28
|
+
process.env.master = 'texttypes';
|
|
29
|
+
fs.writeFileSync(
|
|
30
|
+
path.join(envDir, 'env.texttypes.json'),
|
|
31
|
+
JSON.stringify({
|
|
32
|
+
TextCtx: {
|
|
33
|
+
type: 'better-sqlite3',
|
|
34
|
+
connection: dbDir + path.sep,
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const { default: EntityModel } = await import('../Entity/entityModel.js');
|
|
40
|
+
const { default: SQLiteQuery } = await import('../Migrations/migrationSQLiteQuery.js');
|
|
41
|
+
const { default: MySQLQuery } = await import('../Migrations/migrationMySQLQuery.js');
|
|
42
|
+
const { default: PostgresQuery } = await import('../Migrations/migrationPostgresQuery.js');
|
|
43
|
+
|
|
44
|
+
//
|
|
45
|
+
// EntityModel — the fluent builder must record the new types.
|
|
46
|
+
//
|
|
47
|
+
test('EntityModel.text() sets type to "text"', () => {
|
|
48
|
+
const m = new EntityModel('m');
|
|
49
|
+
m.text();
|
|
50
|
+
assert.equal(m.obj.type, 'text');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('EntityModel.mediumtext() sets type to "mediumtext"', () => {
|
|
54
|
+
const m = new EntityModel('m');
|
|
55
|
+
m.mediumtext();
|
|
56
|
+
assert.equal(m.obj.type, 'mediumtext');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('EntityModel.longtext() sets type to "longtext"', () => {
|
|
60
|
+
const m = new EntityModel('m');
|
|
61
|
+
m.longtext();
|
|
62
|
+
assert.equal(m.obj.type, 'longtext');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
//
|
|
66
|
+
// MySQL — emits TEXT / MEDIUMTEXT / LONGTEXT
|
|
67
|
+
//
|
|
68
|
+
test('MySQL emits TEXT for text', () => {
|
|
69
|
+
const q = new MySQLQuery();
|
|
70
|
+
assert.equal(q.typeManager('text'), 'TEXT');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('MySQL emits MEDIUMTEXT for mediumtext', () => {
|
|
74
|
+
const q = new MySQLQuery();
|
|
75
|
+
assert.equal(q.typeManager('mediumtext'), 'MEDIUMTEXT');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('MySQL emits LONGTEXT for longtext', () => {
|
|
79
|
+
const q = new MySQLQuery();
|
|
80
|
+
assert.equal(q.typeManager('longtext'), 'LONGTEXT');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
//
|
|
84
|
+
// Postgres — collapses all three to TEXT (TEXT is unlimited on PG)
|
|
85
|
+
//
|
|
86
|
+
test('Postgres emits TEXT for text', () => {
|
|
87
|
+
const q = new PostgresQuery();
|
|
88
|
+
assert.equal(q.typeManager('text'), 'TEXT');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('Postgres emits TEXT for mediumtext', () => {
|
|
92
|
+
const q = new PostgresQuery();
|
|
93
|
+
assert.equal(q.typeManager('mediumtext'), 'TEXT');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('Postgres emits TEXT for longtext', () => {
|
|
97
|
+
const q = new PostgresQuery();
|
|
98
|
+
assert.equal(q.typeManager('longtext'), 'TEXT');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
//
|
|
102
|
+
// SQLite — collapses all three to TEXT (TEXT is unlimited on SQLite)
|
|
103
|
+
//
|
|
104
|
+
test('SQLite createTable for "text" column emits TEXT (regression for missing case)', () => {
|
|
105
|
+
const q = new SQLiteQuery();
|
|
106
|
+
const table = {
|
|
107
|
+
__name: 'Note',
|
|
108
|
+
body: { name: 'body', type: 'text', nullable: true },
|
|
109
|
+
};
|
|
110
|
+
const sql = q.createTable(table);
|
|
111
|
+
assert.match(sql, /\bbody\s+TEXT\b/i, `SQLite should emit "body TEXT"; got ${sql}`);
|
|
112
|
+
assert.doesNotMatch(sql, /undefined/, 'SQLite must not emit "undefined" as a type');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('SQLite createTable for "mediumtext" emits TEXT', () => {
|
|
116
|
+
const q = new SQLiteQuery();
|
|
117
|
+
const table = {
|
|
118
|
+
__name: 'Note',
|
|
119
|
+
body: { name: 'body', type: 'mediumtext', nullable: true },
|
|
120
|
+
};
|
|
121
|
+
const sql = q.createTable(table);
|
|
122
|
+
assert.match(sql, /\bbody\s+TEXT\b/i);
|
|
123
|
+
assert.doesNotMatch(sql, /MEDIUMTEXT/i, 'SQLite has no MEDIUMTEXT type');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('SQLite createTable for "longtext" emits TEXT', () => {
|
|
127
|
+
const q = new SQLiteQuery();
|
|
128
|
+
const table = {
|
|
129
|
+
__name: 'Note',
|
|
130
|
+
body: { name: 'body', type: 'longtext', nullable: true },
|
|
131
|
+
};
|
|
132
|
+
const sql = q.createTable(table);
|
|
133
|
+
assert.match(sql, /\bbody\s+TEXT\b/i);
|
|
134
|
+
assert.doesNotMatch(sql, /LONGTEXT/i, 'SQLite has no LONGTEXT type');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
//
|
|
138
|
+
// End-to-end on SQLite — define an entity with all three text types and
|
|
139
|
+
// verify the table is created with TEXT columns.
|
|
140
|
+
//
|
|
141
|
+
test('SQLite end-to-end: entity with text/mediumtext/longtext creates table with TEXT columns', async () => {
|
|
142
|
+
const { default: context } = await import('../context.js');
|
|
143
|
+
|
|
144
|
+
class Document {
|
|
145
|
+
id(db) { db.integer().primary().auto(); }
|
|
146
|
+
small(db) { db.text(); }
|
|
147
|
+
medium(db) { db.mediumtext(); }
|
|
148
|
+
large(db) { db.longtext(); }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
class TextCtx extends context {
|
|
152
|
+
constructor() {
|
|
153
|
+
super();
|
|
154
|
+
this.env(envDir);
|
|
155
|
+
this.dbset(Document);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const ctx = new TextCtx();
|
|
160
|
+
const q = new SQLiteQuery();
|
|
161
|
+
const sql = q.createTable(ctx.Document.__entity);
|
|
162
|
+
assert.match(sql, /\bsmall\s+TEXT\b/i);
|
|
163
|
+
assert.match(sql, /\bmedium\s+TEXT\b/i);
|
|
164
|
+
assert.match(sql, /\blarge\s+TEXT\b/i);
|
|
165
|
+
assert.doesNotMatch(sql, /undefined/);
|
|
166
|
+
await ctx.close();
|
|
167
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|