joinQuery+=" LEFT OUTER JOIN `"+table+"` AS `"+as+"` ON `"+tableLeft+"`.`"+attrLeft+"` = `"+tableRight+"`.`"+attrRight+"`"
joinQuery+=" LEFT OUTER JOIN "+this.quoteIdentifier(table)+" AS "+this.quoteIdentifier(as)+" ON "+this.quoteIdentifier(tableLeft)+"."+this.quoteIdentifier(attrLeft)+" = "+this.quoteIdentifier(tableRight)+"."+this.quoteIdentifier(attrRight)
varquery='SELECT c.column_name as "Field", c.column_default as "Default", c.is_nullable as "Null", c.data_type as "Type", (SELECT array_agg(e.enumlabel) FROM pg_catalog.pg_type t JOIN pg_catalog.pg_enum e ON t.oid=e.enumtypid WHERE t.typname=c.udt_name) AS special FROM information_schema.columns c WHERE table_name = <%= table %>;'
joinQuery+=" LEFT OUTER JOIN `"+table+"` AS `"+as+"` ON `"+tableLeft+"`.`"+attrLeft+"` = `"+tableRight+"`.`"+attrRight+"`"
joinQuery+=" LEFT OUTER JOIN "+this.quoteIdentifier(table)+" AS "+this.quoteIdentifier(as)+" ON "+this.quoteIdentifier(tableLeft)+"."+this.quoteIdentifier(attrLeft)+" = "+this.quoteIdentifier(tableRight)+"."+this.quoteIdentifier(attrRight)+""
@param {Boolean} [options.native=false] A flag that defines if native library shall be used or not.
@param {Boolean} [options.replication=false] I have absolutely no idea.
@param {Object} [options.pool={}] Something.
@param {Boolean} [options.quoteIdentifiers=true] Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of them.
arguments:['myTable',{title:'VARCHAR(255)',name:'VARCHAR(255)',otherId:'INTEGER REFERENCES "otherTable" ("id") ON DELETE CASCADE ON UPDATE NO ACTION'}],
expectation:"CREATE TABLE IF NOT EXISTS \"myTable\" (\"title\" VARCHAR(255), \"name\" VARCHAR(255), \"otherId\" INTEGER REFERENCES \"otherTable\" (\"id\") ON DELETE CASCADE ON UPDATE NO ACTION);"
expectation:"DROP TYPE IF EXISTS enum_myTable_title; CREATE TYPE enum_myTable_title AS ENUM(\"A\", \"B\", \"C\"); CREATE TABLE IF NOT EXISTS myTable (title enum_myTable_title, name VARCHAR(255));",
expectation:"CREATE TABLE IF NOT EXISTS myTable (title VARCHAR(255), name VARCHAR(255), id INTEGER , PRIMARY KEY (id));",
context:{options:{quoteIdentifiers:false}}
},
{
arguments:['myTable',{title:'VARCHAR(255)',name:'VARCHAR(255)',otherId:'INTEGER REFERENCES otherTable (id) ON DELETE CASCADE ON UPDATE NO ACTION'}],
expectation:"CREATE TABLE IF NOT EXISTS myTable (title VARCHAR(255), name VARCHAR(255), otherId INTEGER REFERENCES otherTable (id) ON DELETE CASCADE ON UPDATE NO ACTION);",
expectation:"INSERT INTO myTable (name,nullValue) VALUES ('foo',NULL),('bar',NULL) RETURNING *;",
context:{options:{omitNull:true,quoteIdentifiers:false}}// Note: We don't honour this because it makes little sense when some rows may have nulls and others not
expectation:"INSERT INTO mySchema.myTable (name) VALUES ('foo'),('bar') RETURNING *;",
context:{options:{quoteIdentifiers:false}}
},{
arguments:['mySchema.myTable',[{name:JSON.stringify({info:'Look ma a " quote'})},{name:JSON.stringify({info:'Look ma another " quote'})}]],
expectation:"INSERT INTO mySchema.myTable (name) VALUES ('{\"info\":\"Look ma a \\\" quote\"}'),('{\"info\":\"Look ma another \\\" quote\"}') RETURNING *;",