From 56eafe3de27b476a32c2085e220c5a1117898ae6 Mon Sep 17 00:00:00 2001 From: zongor Date: Mon, 27 May 2024 20:29:39 -0400 Subject: [PATCH] fix foreign key generation --- tools/js-class-c-struct-transpiler/transpile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/js-class-c-struct-transpiler/transpile.js b/tools/js-class-c-struct-transpiler/transpile.js index 0153c42..cced04d 100644 --- a/tools/js-class-c-struct-transpiler/transpile.js +++ b/tools/js-class-c-struct-transpiler/transpile.js @@ -178,8 +178,8 @@ for (const type of Object.keys(schema)) { const foreignKey = `${propType.toLowerCase()}_id`; const localKey = `${prop.toLowerCase()}_${foreignKey}`; - sqlData += `,${localKey} INTEGER`; - foreignKeys += `\nFOREIGN KEY(${localKey}) REFERENCES ${propType}(${foreignKey})` + sqlData += `, ${localKey} INTEGER`; + foreignKeys += `\n, FOREIGN KEY(${localKey}) REFERENCES ${propType}(${foreignKey})` cData += `\n\t\t${types[propType].c} ${prop};`; break; case "array": @@ -205,7 +205,7 @@ for (const type of Object.keys(schema)) { jsData += jsStructConstructor(size, containsString); jsData += `\n}\n\nexport default ${type}`; cData += `\n} ${type};\n\n`; - sqlData += `)${foreignKeys};\n\n`; + sqlData += `${foreignKeys});\n\n`; await Bun.write( Bun.file(values.javascript_out + type + ".js"),