SQLite in Android adding quotes to start and end of datelike stringIs there a way to run Python on Android?How do save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?How do I check in SQLite whether a table exists?Improve INSERT-per-second performance of SQLite?What are the best practices for SQLite on Android?Is there a unique Android device ID?What is 'Context' on Android?Proper use cases for Android UserManager.isUserAGoat()?

I caught several of my students plagiarizing. Could it be my fault as a teacher?

What was the state of the German rail system in 1944?

Type-check an expression

Sed Usage to update GRUB file

Would glacier 'trees' be plausible?

Can fracking help reduce CO2?

What are the differences between credential stuffing and password spraying?

Why is Arya visibly scared in the library in S8E3?

SFINAE works with deduction but fails with substitution

Should one double the thirds or the fifth in chords?

How can I get a job without pushing my family's income into a higher tax bracket?

Where can I go to avoid planes overhead?

My ID is expired, can I fly to the Bahamas with my passport?

Is a lifestealing melee cantrip, in the form of booming blade, unbalanced?

Pressure inside an infinite ocean?

Identifying a transmission to myself

What happens if I start too many background jobs?

Do I have to make someone coauthor if he/she solves a problem in StackExchange, asked by myself, which is later used in my paper?

Meaning of the last sentence of the kaddish?

Can Ghost kill White Walkers or Wights?

Pressure to defend the relevance of one's area of mathematics

What actually is the vector of angular momentum?

A non-technological, repeating, phenomenon in the sky, holding its position in the sky for hours

If Earth is tilted, why is Polaris always above the same spot?



SQLite in Android adding quotes to start and end of datelike string


Is there a way to run Python on Android?How do save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?How do I check in SQLite whether a table exists?Improve INSERT-per-second performance of SQLite?What are the best practices for SQLite on Android?Is there a unique Android device ID?What is 'Context' on Android?Proper use cases for Android UserManager.isUserAGoat()?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Interesting issue while using SQLite in Android. I am seeing an inconsistency in the string length and quoting of a string between what is stored in the database and the materialized value seen in Java.



We are using an ORM called SugarORM to query the DB, but I've traced the offending code to the internal android.database.sqlite.SQLiteCursor class used within SugarORM, specifically the cursor.getString(columnIndex) method.



I have a string in the database that is an ISO data string 2019-03-25T19:19:39.664Z and is stored in a VARCHAR column . I have confirmed using DB Browser for SQLite that the length of the string as its stored in the database is indeed 24 characters. SELECT LENGTH(MyStringColumn) FROM MyTable WHERE ...



When I get the value of this string via cursor.getString(columnIndex), it is returning the string "2019-03-25T19:19:39.664Z". Notice the leading and trailing quotes. Java reports to me that the string is 26 characters long.



Any value that I store in this column that is not an ISO data does not have this behavior. I tried tracing the SQLiteCursor source back, but ultimately it ends up being a Native method and that's where my skill set stops.



Can anyone explain what might be going on here? I am probably just going to write a wrapper around my queries to get rid of the quotes, but its all very perplexing. The date string is being fed to a JavaScript interpreter and causing it to fail when creating a JavaScript Date object.



If it helps, I have replicated the behavior on both my S7 physical device and a Pixel 6 emulator.










share|improve this question






















  • Show the relevant code that retrieves the data.

    – Shawn
    Mar 22 at 22:00

















0















Interesting issue while using SQLite in Android. I am seeing an inconsistency in the string length and quoting of a string between what is stored in the database and the materialized value seen in Java.



We are using an ORM called SugarORM to query the DB, but I've traced the offending code to the internal android.database.sqlite.SQLiteCursor class used within SugarORM, specifically the cursor.getString(columnIndex) method.



I have a string in the database that is an ISO data string 2019-03-25T19:19:39.664Z and is stored in a VARCHAR column . I have confirmed using DB Browser for SQLite that the length of the string as its stored in the database is indeed 24 characters. SELECT LENGTH(MyStringColumn) FROM MyTable WHERE ...



When I get the value of this string via cursor.getString(columnIndex), it is returning the string "2019-03-25T19:19:39.664Z". Notice the leading and trailing quotes. Java reports to me that the string is 26 characters long.



Any value that I store in this column that is not an ISO data does not have this behavior. I tried tracing the SQLiteCursor source back, but ultimately it ends up being a Native method and that's where my skill set stops.



Can anyone explain what might be going on here? I am probably just going to write a wrapper around my queries to get rid of the quotes, but its all very perplexing. The date string is being fed to a JavaScript interpreter and causing it to fail when creating a JavaScript Date object.



If it helps, I have replicated the behavior on both my S7 physical device and a Pixel 6 emulator.










share|improve this question






















  • Show the relevant code that retrieves the data.

    – Shawn
    Mar 22 at 22:00













0












0








0








Interesting issue while using SQLite in Android. I am seeing an inconsistency in the string length and quoting of a string between what is stored in the database and the materialized value seen in Java.



We are using an ORM called SugarORM to query the DB, but I've traced the offending code to the internal android.database.sqlite.SQLiteCursor class used within SugarORM, specifically the cursor.getString(columnIndex) method.



I have a string in the database that is an ISO data string 2019-03-25T19:19:39.664Z and is stored in a VARCHAR column . I have confirmed using DB Browser for SQLite that the length of the string as its stored in the database is indeed 24 characters. SELECT LENGTH(MyStringColumn) FROM MyTable WHERE ...



When I get the value of this string via cursor.getString(columnIndex), it is returning the string "2019-03-25T19:19:39.664Z". Notice the leading and trailing quotes. Java reports to me that the string is 26 characters long.



Any value that I store in this column that is not an ISO data does not have this behavior. I tried tracing the SQLiteCursor source back, but ultimately it ends up being a Native method and that's where my skill set stops.



Can anyone explain what might be going on here? I am probably just going to write a wrapper around my queries to get rid of the quotes, but its all very perplexing. The date string is being fed to a JavaScript interpreter and causing it to fail when creating a JavaScript Date object.



If it helps, I have replicated the behavior on both my S7 physical device and a Pixel 6 emulator.










share|improve this question














Interesting issue while using SQLite in Android. I am seeing an inconsistency in the string length and quoting of a string between what is stored in the database and the materialized value seen in Java.



We are using an ORM called SugarORM to query the DB, but I've traced the offending code to the internal android.database.sqlite.SQLiteCursor class used within SugarORM, specifically the cursor.getString(columnIndex) method.



I have a string in the database that is an ISO data string 2019-03-25T19:19:39.664Z and is stored in a VARCHAR column . I have confirmed using DB Browser for SQLite that the length of the string as its stored in the database is indeed 24 characters. SELECT LENGTH(MyStringColumn) FROM MyTable WHERE ...



When I get the value of this string via cursor.getString(columnIndex), it is returning the string "2019-03-25T19:19:39.664Z". Notice the leading and trailing quotes. Java reports to me that the string is 26 characters long.



Any value that I store in this column that is not an ISO data does not have this behavior. I tried tracing the SQLiteCursor source back, but ultimately it ends up being a Native method and that's where my skill set stops.



Can anyone explain what might be going on here? I am probably just going to write a wrapper around my queries to get rid of the quotes, but its all very perplexing. The date string is being fed to a JavaScript interpreter and causing it to fail when creating a JavaScript Date object.



If it helps, I have replicated the behavior on both my S7 physical device and a Pixel 6 emulator.







android sqlite sugarorm






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 22 at 21:04









Jeremy NoonanJeremy Noonan

362




362












  • Show the relevant code that retrieves the data.

    – Shawn
    Mar 22 at 22:00

















  • Show the relevant code that retrieves the data.

    – Shawn
    Mar 22 at 22:00
















Show the relevant code that retrieves the data.

– Shawn
Mar 22 at 22:00





Show the relevant code that retrieves the data.

– Shawn
Mar 22 at 22:00












1 Answer
1






active

oldest

votes


















0














As a quick get around you could use :-



SELECT length(replace(mystringcolumn,'"','')) FROM mytable;


or before using the original SELECT use :-



UPDATE mytable SET mystringcolumn = replace(mystringcolumn,'"','');


  • If this doesn't fix the issue, then for some reason it is the code that retrieves the data that is at fault.

e.g. consider :-



DROP TABLE IF EXISTS mytable;
CREATE TABLE IF NOT EXISTS mytable (mystringcolumn VARCHAR);
INSERT INTO mytable VALUES('2019-03-25T19:19:39.664Z'),('"2019-03-25T19:19:39.664Z"');
SELECT length(mystringcolumn), length(replace(mystringcolumn,'"','')) FROM mytable;


which results in :-



enter image description here



i.e. The 2nd row, 2nd column retrieves the appropriate value by using the replace function to strip of the quotes, if they exist.



As to why the quotes exist could depend upon either the way that the data is inserted (perhaps you have inadvertenly coded the quotes but the db being looked at isn't the actual database as copied from the App) or the way in which the data is being retrieved that for some reason adds them.



I don't believe it likely that the Cursor getString method has a bug in which the quotes are added, otherwise such an issue would likely be a recurring issue.






share|improve this answer

























  • I totally agree with getString not being at fault. Certainly such behavior would have been discovered long ago? I did open the exact database file on my Android device via the DeviceExplorer in AndroidStudio, so I feel like I should be looking at the data correctly. I am going to put a wrapper around our ORM for now, but seems like a hack.

    – Jeremy Noonan
    Mar 23 at 14:15











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307749%2fsqlite-in-android-adding-quotes-to-start-and-end-of-datelike-string%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














As a quick get around you could use :-



SELECT length(replace(mystringcolumn,'"','')) FROM mytable;


or before using the original SELECT use :-



UPDATE mytable SET mystringcolumn = replace(mystringcolumn,'"','');


  • If this doesn't fix the issue, then for some reason it is the code that retrieves the data that is at fault.

e.g. consider :-



DROP TABLE IF EXISTS mytable;
CREATE TABLE IF NOT EXISTS mytable (mystringcolumn VARCHAR);
INSERT INTO mytable VALUES('2019-03-25T19:19:39.664Z'),('"2019-03-25T19:19:39.664Z"');
SELECT length(mystringcolumn), length(replace(mystringcolumn,'"','')) FROM mytable;


which results in :-



enter image description here



i.e. The 2nd row, 2nd column retrieves the appropriate value by using the replace function to strip of the quotes, if they exist.



As to why the quotes exist could depend upon either the way that the data is inserted (perhaps you have inadvertenly coded the quotes but the db being looked at isn't the actual database as copied from the App) or the way in which the data is being retrieved that for some reason adds them.



I don't believe it likely that the Cursor getString method has a bug in which the quotes are added, otherwise such an issue would likely be a recurring issue.






share|improve this answer

























  • I totally agree with getString not being at fault. Certainly such behavior would have been discovered long ago? I did open the exact database file on my Android device via the DeviceExplorer in AndroidStudio, so I feel like I should be looking at the data correctly. I am going to put a wrapper around our ORM for now, but seems like a hack.

    – Jeremy Noonan
    Mar 23 at 14:15















0














As a quick get around you could use :-



SELECT length(replace(mystringcolumn,'"','')) FROM mytable;


or before using the original SELECT use :-



UPDATE mytable SET mystringcolumn = replace(mystringcolumn,'"','');


  • If this doesn't fix the issue, then for some reason it is the code that retrieves the data that is at fault.

e.g. consider :-



DROP TABLE IF EXISTS mytable;
CREATE TABLE IF NOT EXISTS mytable (mystringcolumn VARCHAR);
INSERT INTO mytable VALUES('2019-03-25T19:19:39.664Z'),('"2019-03-25T19:19:39.664Z"');
SELECT length(mystringcolumn), length(replace(mystringcolumn,'"','')) FROM mytable;


which results in :-



enter image description here



i.e. The 2nd row, 2nd column retrieves the appropriate value by using the replace function to strip of the quotes, if they exist.



As to why the quotes exist could depend upon either the way that the data is inserted (perhaps you have inadvertenly coded the quotes but the db being looked at isn't the actual database as copied from the App) or the way in which the data is being retrieved that for some reason adds them.



I don't believe it likely that the Cursor getString method has a bug in which the quotes are added, otherwise such an issue would likely be a recurring issue.






share|improve this answer

























  • I totally agree with getString not being at fault. Certainly such behavior would have been discovered long ago? I did open the exact database file on my Android device via the DeviceExplorer in AndroidStudio, so I feel like I should be looking at the data correctly. I am going to put a wrapper around our ORM for now, but seems like a hack.

    – Jeremy Noonan
    Mar 23 at 14:15













0












0








0







As a quick get around you could use :-



SELECT length(replace(mystringcolumn,'"','')) FROM mytable;


or before using the original SELECT use :-



UPDATE mytable SET mystringcolumn = replace(mystringcolumn,'"','');


  • If this doesn't fix the issue, then for some reason it is the code that retrieves the data that is at fault.

e.g. consider :-



DROP TABLE IF EXISTS mytable;
CREATE TABLE IF NOT EXISTS mytable (mystringcolumn VARCHAR);
INSERT INTO mytable VALUES('2019-03-25T19:19:39.664Z'),('"2019-03-25T19:19:39.664Z"');
SELECT length(mystringcolumn), length(replace(mystringcolumn,'"','')) FROM mytable;


which results in :-



enter image description here



i.e. The 2nd row, 2nd column retrieves the appropriate value by using the replace function to strip of the quotes, if they exist.



As to why the quotes exist could depend upon either the way that the data is inserted (perhaps you have inadvertenly coded the quotes but the db being looked at isn't the actual database as copied from the App) or the way in which the data is being retrieved that for some reason adds them.



I don't believe it likely that the Cursor getString method has a bug in which the quotes are added, otherwise such an issue would likely be a recurring issue.






share|improve this answer















As a quick get around you could use :-



SELECT length(replace(mystringcolumn,'"','')) FROM mytable;


or before using the original SELECT use :-



UPDATE mytable SET mystringcolumn = replace(mystringcolumn,'"','');


  • If this doesn't fix the issue, then for some reason it is the code that retrieves the data that is at fault.

e.g. consider :-



DROP TABLE IF EXISTS mytable;
CREATE TABLE IF NOT EXISTS mytable (mystringcolumn VARCHAR);
INSERT INTO mytable VALUES('2019-03-25T19:19:39.664Z'),('"2019-03-25T19:19:39.664Z"');
SELECT length(mystringcolumn), length(replace(mystringcolumn,'"','')) FROM mytable;


which results in :-



enter image description here



i.e. The 2nd row, 2nd column retrieves the appropriate value by using the replace function to strip of the quotes, if they exist.



As to why the quotes exist could depend upon either the way that the data is inserted (perhaps you have inadvertenly coded the quotes but the db being looked at isn't the actual database as copied from the App) or the way in which the data is being retrieved that for some reason adds them.



I don't believe it likely that the Cursor getString method has a bug in which the quotes are added, otherwise such an issue would likely be a recurring issue.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 23 at 3:04

























answered Mar 22 at 23:51









MikeTMikeT

18.9k112844




18.9k112844












  • I totally agree with getString not being at fault. Certainly such behavior would have been discovered long ago? I did open the exact database file on my Android device via the DeviceExplorer in AndroidStudio, so I feel like I should be looking at the data correctly. I am going to put a wrapper around our ORM for now, but seems like a hack.

    – Jeremy Noonan
    Mar 23 at 14:15

















  • I totally agree with getString not being at fault. Certainly such behavior would have been discovered long ago? I did open the exact database file on my Android device via the DeviceExplorer in AndroidStudio, so I feel like I should be looking at the data correctly. I am going to put a wrapper around our ORM for now, but seems like a hack.

    – Jeremy Noonan
    Mar 23 at 14:15
















I totally agree with getString not being at fault. Certainly such behavior would have been discovered long ago? I did open the exact database file on my Android device via the DeviceExplorer in AndroidStudio, so I feel like I should be looking at the data correctly. I am going to put a wrapper around our ORM for now, but seems like a hack.

– Jeremy Noonan
Mar 23 at 14:15





I totally agree with getString not being at fault. Certainly such behavior would have been discovered long ago? I did open the exact database file on my Android device via the DeviceExplorer in AndroidStudio, so I feel like I should be looking at the data correctly. I am going to put a wrapper around our ORM for now, but seems like a hack.

– Jeremy Noonan
Mar 23 at 14:15



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307749%2fsqlite-in-android-adding-quotes-to-start-and-end-of-datelike-string%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해