问题描述
我正在从tableA
中选择行,并使用tableB
将结果行插入到knexJS
中。 tableA
和tableB
在Redshift
数据库中具有相同的架构。
列名和类型
-
id - int
-
created_date - timestamp without timezone
knex(tableB)
.insert(function() {
this.select()
.from(tableA)
.whereRaw('id=?',['12345']);
});
error: column \"created_date\" is of type timestamp without time zone but expression is of type character varying
如何在代码中解决此问题?由于许多原因,更新数据库连接属性将非常非常困难。
任何线索/帮助/建议将不胜感激
解决方法
也许您正在尝试这样做:
knex('table1')
.insert(
knex.raw("?",[ knex('table2').where('id','12345') ])
);
输出:
insert into "table1" (select * from "table2" where "id" = ?)