forked from brianc/node-sql
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I'm trying to generate SQL create DDL from a SQL define using this code:
const post = this.sql.define<{ id: number; title: string; body: string }>({
name: 'post',
columns: ['id', 'title', 'body']
});
try {
let query = post.create().toQuery();
console.log("Create Query " + query.text)
return query;
}
catch (e) {
console.log("ERROR " + e.message + " STACK " + e.stack)
}
This generates an error: ERROR dataType missing for column id (CREATE TABLE and ADD COLUMN statements require a dataType).
I can get the define to work by changing the columns in the define to:
columns: [{name: 'id', dataType: "number"}, {name:'title', dataType: "string"}, {name:'body', dataType: "string"}]
This will generate the create DDL: "CREATE TABLE post (id number, title string, body string)"
What are the valid values for dataType and is there a way that they can be converted to the correct type for the database (e.g. string might be varchar(255)?
Metadata
Metadata
Assignees
Labels
No labels