[英]Why execSQL accepts Object[] and raw Query String[]
I would like to have an option to call 'rawQuery' with a list of Integers passed into it, but it looks I can't: all 'rawQuery' methods require array of Strings... 我想有一个选项来调用'rawQuery',并传递一个整数列表,但看起来我做不到:所有'rawQuery'方法都需要字符串数组...
Why? 为什么? I can call 'toString' for each passed int object, but I don't see any logic here.
我可以为每个传递的int对象调用'toString',但是在这里看不到任何逻辑。 Why Google don't provide rawQuery that accept list of Objects?
为什么Google不提供接受对象列表的rawQuery?
Are there any limitation or constrains for that? 是否有任何限制或约束?
Probably I miss something? 可能我想念什么吗?
Thank you. 谢谢。
Probably because rawQuery isn't the prefered method of querying. 可能是因为rawQuery不是首选的查询方法。 And since sqlite columns basically don't have types, they probably don't want to assume calling toString on whatever it is you're passing.
而且由于sqlite列基本上没有类型,所以它们可能不想假设对要传递的内容调用toString。
SQLite supports the concept of "type affinity" on columns.
SQLite支持列上的“类型相似性”概念。 The type affinity of a column is the recommended type for data stored in that column.
列的类型相似性是存储在该列中的数据的推荐类型。 The important idea here is that the type is recommended, not required.
这里的重要思想是建议类型,而不是必需类型。 Any column can still store any type of data.
任何列仍可以存储任何类型的数据。 It is just that some columns, given the choice, will prefer to use one storage class over another.
只是有些列(如果有选择)将更喜欢使用一种存储类而不是另一种。 The preferred storage class for a column is called its "affinity".
列的首选存储类称为其“关联性”。
Is there a reason you want to use rawQuery
instead of execSQL
? 您是否有理由要使用
rawQuery
而不是execSQL
?
No complex objects are accepted in the list of parameters, as stated on the documentation for the parameter bindArgs : 如参数bindArgs的文档中所述,参数列表中不接受任何复杂对象:
Parameters 参量
sql the SQL statement to be executed. sql要执行的SQL语句。 Multiple statements separated by semicolons are not supported.
不支持用分号分隔的多个语句。
bindArgs only byte[], String, Long and Double are supported in bindArgs. bindArgs只支持byte [],String,Long和Double的bindArgs。
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#execSQL(java.lang.String, java.lang.Object[]) . http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#execSQL(java.lang.String,java.lang.Object []) 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.