sqlite - rails: How to find entries with empty arrays -


i've got issue finding empty arrays in sqlite table.

i serialized product_category param, works saving arrays db, follows:

serialize :product_category, array 

the following query find empty arrays param, giving me nil error:

product.where(product_category: []).first 

how find products product_category has no values in array?

i tried using {} instead of [] suggested in similar postgress related question.

does know right way?

i have tried on mysql, works me, please try.

#product.rb serialize :product_category, array  #rails console >> product = product.new >> product.product_category = [] >> product.save >> product.where("product_categoty = '[]'") #it returns last record have created. 

hope help!


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -