nexusql 0.9.6 → 0.9.8
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/cli.js +14 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1854,13 +1854,15 @@ var Database = class _Database {
|
|
|
1854
1854
|
async installExtensions(extensions) {
|
|
1855
1855
|
for (const ext of extensions) {
|
|
1856
1856
|
try {
|
|
1857
|
-
|
|
1857
|
+
const needsQuoting = /[^a-z0-9_]/i.test(ext);
|
|
1858
|
+
const quotedExt = needsQuoting ? `"${ext}"` : ext;
|
|
1859
|
+
await this.exec(`CREATE EXTENSION IF NOT EXISTS ${quotedExt};`);
|
|
1858
1860
|
const result = await this.queryParams(
|
|
1859
1861
|
`SELECT EXISTS(SELECT 1 FROM pg_extension WHERE extname = $1) as exists`,
|
|
1860
1862
|
[ext]
|
|
1861
1863
|
);
|
|
1862
1864
|
if (!result.rows[0]?.exists) {
|
|
1863
|
-
throw new Error(`Extension
|
|
1865
|
+
throw new Error(`Extension ${quotedExt} was not installed`);
|
|
1864
1866
|
}
|
|
1865
1867
|
} catch (error) {
|
|
1866
1868
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -3652,8 +3654,16 @@ async function gen(options = {}) {
|
|
|
3652
3654
|
const tempDb = db.withDatabase(tempDbName);
|
|
3653
3655
|
let migrationSql = "";
|
|
3654
3656
|
try {
|
|
3657
|
+
const hasVectorType = targetSql.toLowerCase().includes("vector");
|
|
3658
|
+
const extensions = [...config.extensions];
|
|
3659
|
+
if (hasVectorType && !extensions.includes("vector")) {
|
|
3660
|
+
spinner.info(
|
|
3661
|
+
"Detected 'vector' type usage - auto-enabling vector extension"
|
|
3662
|
+
);
|
|
3663
|
+
extensions.push("vector");
|
|
3664
|
+
}
|
|
3655
3665
|
spinner.start("Installing extensions...");
|
|
3656
|
-
await tempDb.installExtensions(
|
|
3666
|
+
await tempDb.installExtensions(extensions);
|
|
3657
3667
|
if (config.extensions.includes("vector")) {
|
|
3658
3668
|
const vectorCheck = await tempDb.query(
|
|
3659
3669
|
"SELECT typname FROM pg_type WHERE typname = 'vector'"
|
|
@@ -3668,9 +3678,7 @@ async function gen(options = {}) {
|
|
|
3668
3678
|
spinner.succeed("Installed db extensions");
|
|
3669
3679
|
spinner.start("Loading schema into temp database...");
|
|
3670
3680
|
if (targetSql.toLowerCase().includes("vector")) {
|
|
3671
|
-
const vectorLines = targetSql.split("\n").filter(
|
|
3672
|
-
(line) => line.toLowerCase().includes("vector")
|
|
3673
|
-
);
|
|
3681
|
+
const vectorLines = targetSql.split("\n").filter((line) => line.toLowerCase().includes("vector"));
|
|
3674
3682
|
console.log("\n[DEBUG] SQL lines with 'vector':");
|
|
3675
3683
|
vectorLines.forEach((line) => console.log(" ", line.trim()));
|
|
3676
3684
|
console.log("");
|