In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

SQLite Bug on date fields

Xailer professional forum in English
Responder
Avatar de Usuario
emeasoft
Mensajes: 1088
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

SQLite Bug on date fields

Mensaje por emeasoft »

Hello Xailers,

It seems there is a weird bug with the date fields, using the command ATTACH from sqlite to copy a table and its contents, all the date fields were saved as numeric values.

See the example for more detailed info about this error.

What could be causing this?

TIA,
Juliano
Adjuntos
TestSQLite.zip
(50.16 KiB) Descargado 220 veces
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9253
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: SQLite Bug on date fields

Mensaje por ignacio »

Hi,

We are working on this problem right now. BTW, in our tests with oDS:lDateAsString to .T. works correctly. I recommend to use lDateAsString to .T., it uses more disk space, but is the standard on SQLite databases. In any case we hope to have a fix for this problem ASAP.

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
emeasoft
Mensajes: 1088
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

Re: SQLite Bug on date fields

Mensaje por emeasoft »

Many thanks Ignacio!

We are going to take a look on the lDateAsString while we wait for the fix then.

Regards,
Juliano
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9253
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: SQLite Bug on date fields

Mensaje por ignacio »

emeasoft escribió:Many thanks Ignacio!

We are going to take a look on the lDateAsString while we wait for the fix then.

Regards,
Juliano
Juliano,

Please try with the files attached (.obj for Borland and .o for MinGW) . TIA.

Regards,
Adjuntos
isqlite.rar
(12.7 KiB) Descargado 227 veces
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
emeasoft
Mensajes: 1088
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

Re: SQLite Bug on date fields

Mensaje por emeasoft »

Hello Ignacio,

I tested with the .o file but the error still persists.
error.png
error.png (51.65 KiB) Visto 6123 veces
Regards,
Juliano
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9253
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: SQLite Bug on date fields

Mensaje por ignacio »

Hello Juliano,

I attach with this message the two DBs created by me with the modification I sent you. They look fine. Maybe the object module did not get really linked to the executable. Please try a complete recompile.

BTW, in order to force the use of the new module I attach with this message the complete Xailer library for MingGw, that you can download from the following link:

https://dl.dropboxusercontent.com/u/318 ... Xailer.zip

Regard,
Adjuntos
sqlite.rar
(727 Bytes) Descargado 221 veces
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
emeasoft
Mensajes: 1088
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

Re: SQLite Bug on date fields

Mensaje por emeasoft »

Thanks Ignacio! It worked now!

Just one more question, the date fields on the database created by the attach command are returning as char, not date as on the original table.

Is there any fix for this?

TIA,
Juliano
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9253
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: SQLite Bug on date fields

Mensaje por ignacio »

emeasoft escribió:Thanks Ignacio! It worked now!

Just one more question, the date fields on the database created by the attach command are returning as char, not date as on the original table.

Is there any fix for this?

TIA,
Juliano
Hi Juliano,

There is some extra work to do since the select clause you use does not give the necessary information. Change this code:

Código: Seleccionar todo

::dSQL:Execute( "CREATE TABLE LXTMP.TAB1 AS SELECT * FROM TAB1" )
To this:

Código: Seleccionar todo

   Local aSql, aHead, cSql

   ::dSQL:Execute( "SELECT sql FROM SQLITE_MASTER WHERE TYPE = 'table' and upper( tbl_name ) = 'TAB1'",, @aSql )
   cSql := Strtran( aSql[1,1], "CREATE TABLE TAB1", "CREATE TABLE LXTMP.TAB1" )
   ::dSQL:Execute( cSql ) // Creates the new table
   ::dSQL:QueryRow( "Select * from TAB1 LIMIT 1", @aHead )
   cSql := "INSERT INTO LXTMP.TAB1("
   AEval( aHead, {|v| cSql += v + "," } )
   SwapChr( @cSql, Len( cSql ), ")" )
   cSql += " SELECT * FROM TAB1"
   ::dSQL:Execute( cSql )
Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Responder