简体   繁体   English

错误:运算符不存在:没有时区的时间戳 > 整数)

[英]ERROR: operator does not exist: timestamp without time zone > integer)

I am using Rails 5.2 and passing a date parameter.我正在使用 Rails 5.2 并传递一个日期参数。 To simplify my example, look at the below sql query, it is similar but simplified as it is too complex to be used with active record methods, so I need to run the raw sql..为了简化我的例子,请看下面的 sql 查询,它很相似但被简化,因为它太复杂而无法与活动记录方法一起使用,所以我需要运行原始 sql..

sql = 'Select * FROM mytable WHERE created_at > #{@start_date_time}'

1) How do I sanitize the parameters as I pass them into a string or the execute command. 1) 如何在将参数传递到字符串或执行命令时对其进行清理。

2) What format should my date be in? 2)我的日期应该是什么格式? I tried '2018-01-01 00:00:00.000' and '2018-01-01' and both error.我试过 '2018-01-01 00:00:00.000' 和 '2018-01-01' 都出错了。

CODE:代码:

sql =count_query(@start_date_time, sender_type, sender_id)
records_array = ActiveRecord::Base.connection.execute(sql)

ERROR错误

ActiveRecord::StatementInvalid (PG::UndefinedFunction: 
ERROR:  operator does not exist: timestamp without time zone > integer)

LINE 11: WHERE created_at > 2018-01-01

WHERE created_at > '2018-01-01' 应该可以工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:运算符不存在:没有时区的时间戳+整数 - ERROR: operator does not exist: timestamp without time zone + integer 错误:运营商不存在:带时区的时间戳/integer - ERROR: operator does not exist: timestamp with time zone / integer 修复错误:“运算符不存在:没有时区的时间戳>整数”错误 - Fix ERROR: "operator does not exist: timestamp without time zone > integer" error ActiveRecord :: StatementInvalid:PG错误:错误:运算符不存在:没有时区的时间戳> =整数 - ActiveRecord::StatementInvalid: PGError: ERROR: operator does not exist: timestamp without time zone >= integer 运算符不存在:@timestamp without time zone - operator does not exist: @ timestamp without time zone PostgreSQL:运算符不存在:没有时区的时间戳==没有时区的时间戳 - PostgreSQL: operator does not exist: timestamp without time zone == timestamp without time zone PostgreSQL:42883 运算符不存在:没有时区的时间戳 = 文本 - PostgreSQL: 42883 Operator does not exist: timestamp without time zone = text 运算符不存在:没有时区的时间戳~~ *未知的Ruby代码 - operator does not exist: timestamp without time zone ~~* unknown ruby code PostgreSQL:42883运算符不存在:没有时区的时间戳 - PostgreSQL: 42883 Operator does not exist: timestamp without time zone 按日期获取查询 - 错误:运算符不存在:没有时区的时间戳~~未知 - Getting query by date - ERROR: operator does not exist: timestamp without time zone ~~ unknown
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM