I have added some additional search functionality to my app - tested and works fine on Android 4.4.2.
Have just updated my device to 5.0 and this new search functionality doesn't work, returning an empty cursor. (The other queries in the app all work fine on all devices, indicating that this is a code issue rather than a data issue.)
I understand that, from Android 4.4.2 to Android 5.0, SQLite was updated from 3.7.11 to 3.8.0, which I expect is the reason for this issue. I've looked at the changelog for SQLite 3.8.0 and there is nothing that stands out as being of obvious concern (to my untrained eye, anyway).
Here is the query in question that is produced by my code:
SELECT
statuses.status AS status,
shelves.shelf_name AS shelf_name,
aisles.aisle_name AS aisle_name,
products.image_file_name_stored AS image_file_name_stored,
parent_companies.url AS url,
parent_companies.email AS email,
products.buy_url AS buy_url,
products_data.status_id AS status_id,
parent_companies.company_name AS company_name,
products.image_file_name AS image_file_name,
'(' || shelves.shelf_name || ')' AS suggest_text_2,
products._id AS suggest_intent_data_id,
products.product_name AS suggest_text_1,
parent_companies.tel AS tel,
products.product_name AS product_name,
products_data.notes AS notes,
products.priority AS priority,
products._id AS _id,
products_data.last_modified_on AS last_modified_on
FROM
products
INNER JOIN
parent_companies ON products.parent_company_id = parent_companies._id
INNER JOIN
shelves ON products.shelf_id = shelves._id
INNER JOIN
aisles ON shelves.aisle_id = aisles._id
INNER JOIN
products_data ON products._id = products_data.product_id
INNER JOIN
statuses ON products_data.status_id = statuses._id
WHERE
(shelves._id = ?)
ORDER BY
shelf_name ASC
And my selectionArgs = {"156"}.
UPDATE
Now, just to test, I've set the selection String to null and the selectionArgs String[] to null and the cursor is now full of results - too many, of course as there is no longer a WHERE condition.
So, my question is ultimately this... Why does having the following selection criteron gives results in Android 4.4.2 (SQLite 3.7.11) but no results in Android 5.0 (SQLite 3.8.0) ?...
String selection = "shelves._id = ?";
String[] selectionArgs = {"156"};
...surely it's not that I am trying to compare an integer column (_id) with a String ("156") ?!
Aucun commentaire:
Enregistrer un commentaire