Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在Firefox SQLite管理器中将col创建为BOOL时,未在rails 3.1.4的sqlite3中正确保存布尔值_Ruby On Rails_Sqlite - Fatal编程技术网

Ruby on rails 在Firefox SQLite管理器中将col创建为BOOL时,未在rails 3.1.4的sqlite3中正确保存布尔值

Ruby on rails 在Firefox SQLite管理器中将col创建为BOOL时,未在rails 3.1.4的sqlite3中正确保存布尔值,ruby-on-rails,sqlite,Ruby On Rails,Sqlite,在我们的rails 3.1.4应用程序的表记录中有一个cancelled列。最初,cancelled在Firefox SQLite管理器中创建为BOOL,这是软件提供的默认类型。使用rails中的cancelled=false,将false保存到colcancelled的记录表中。问题在于使用记录进行查询时。其中(“Cancelled=?”,false),未选择已取消的为false的记录,因为在sqlite3中false未解释为false。为了选择所有已取消的=false,我们必须进行记录。其中

在我们的rails 3.1.4应用程序的表记录中有一个
cancelled
列。最初,
cancelled
在Firefox SQLite管理器中创建为BOOL,这是软件提供的默认类型。使用rails中的
cancelled=false
,将
false
保存到col
cancelled
的记录表中。问题在于使用
记录进行查询时。其中(“Cancelled=?”,false)
,未选择
已取消的
false的记录,因为在sqlite3中
false
未解释为false。为了选择所有已取消的
=false,我们必须进行
记录。其中(“已取消=?或已取消=?”,false,'false')

在SQLite管理器中将
cancelled
的数据类型从BOOL手动更改为“boolean”后,
记录。其中(“cancelled=?”,false)
可以使用
cancelled
作为
f
拾取新创建的记录。在SQLite管理器中,那些
cancelled
值表示为
f
,rails将其解释为FALSE

如何修复表记录(对于
cancelled
,用'false'表示),以便
record.where(“cancelled=?”,false)
可以工作?非常感谢

更新:在rails控制台中查询表记录时,
cancelled
不作为布尔值(true或false)。
Record.where(“cancelled=?”,true)
Record.where(“cancelled=?”,false)
无法提取列
cancelled
中所有记录的
false
。但是在rails控制台中,为
cancelled
返回的.class仍然是
false类。奇怪,不是吗

UPDATE my_table
   SET canceled = true -- or 1 check the table
 WHERE canceled = 'true'


UPDATE my_table
   SET canceled = false
 WHERE canceled = 'false'
编辑:

试试这个

my_model.update_all( {:canceled => true}, {:canceled => 'true'} )
my_model.update_all( {:canceled => false}, {:canceled => 'false'} )

未在SQLite管理器中工作。“SqlItemManager:可能的SQL语法错误:update lease\u usage\u records set Cancelled=false其中Cancelled='false'[没有这样的列:false]异常名称:NS\u error\u FAILURE异常消息:组件返回故障代码:0x80004005(NS\u error\u FAILURE)[mozIStorageConnection.createStatement]”是的,很抱歉这是SQL server语法,只需修改以适应sqliteQuery在sqlite3上是相同的。