rails mysql事务_在Rails4中将我的数据库从sqlite3切换到mysql时...

在将数据库从SQLite3切换到MySQL之后,遇到一个运行时错误,错误指出MySQL不识别'strftime'函数。查询涉及到筛选状态为'Active'且出生日期按'%d/%m'格式匹配当前日期的员工。这导致了ActionView模板渲染时的错误,影响了页面的正常显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近我将我的数据库从sqlite3更改为mysql.当我运行我的项目时,我在其中一个使用此查询的文件中收到此错误.

date = Date.today 1

@employees = Employee.where(“status =?AND strftime(‘%d /%m’,date_of_birth)=?”,“Active”,date.strftime(‘%d /%m’)

ActionView::Template::Error (Mysql2::Error: FUNCTION hrms_development.strftime does not exist: SELECT COUNT(*) FROM `employees` WHERE (status = 'Active' AND strftime('%d/%m', date_of_birth) = '28/03')):

210:

211:

212:

213:

214:

215:

216:

app/views/home/_group_admin.html.erb:213:in `_app_views_home__group_admin_html_erb___2522183600721478262_91627100'

app/views/home/index.html.erb:17:in `_app_views_home_index_html_erb__2772204906267359422_86967120'

ActionView::Template::Error: Mysql2::Error: FUNCTION hrms_development.strftime does not exist: SELECT COUNT(*) FROM `employees` WHERE (status = 'Active' AND strftime('%d/%m', date_of_birth) = '28/03')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值