#1 2013-02-01 16:47:24

Junior/RO
Member
Registered: 2011-05-13
Posts: 210

Are all char fields created as TEXT?

Hi AB.

I have created this class:

type
  TCertidao = class(TSQLRecord)
  private
    FControle: RawUTF8;
    FData: TDateTime;
    FNumero: RawUTF8;
    FServidor: TServidors;
  published
    property Numero: RawUTF8 index 12 read FNumero write FNumero;
    property Controle: RawUTF8 index 8 read FControle write FControle;
    property Data: TDateTime read FData write FData;
    property Servidor: TServidors read FServidor write FServidor;
  end;

I need the fields Numero as VARCHAR(12) and Controle as VARCHAR(8).

But when I look the sqlite file in SQLite Administrator, they are all TEXT. Field DATA is TEXT too.

How can I correct this?

I am using your current check-in http://synopse.info/fossil/vinfo?name=6 … 9a28ebc547

Last edited by Junior/RO (2013-02-01 16:49:20)

Offline

#2 2013-02-01 18:52:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Are all char fields created as TEXT?

In the SQlite3 engine, there is no field width for TEXT columns.
See http://www.sqlite.org/faq.html#q9

In mORMot, TDateTime fields are stored as ISO-8601 text (as expected by SQlite3 itself for time/date functions, by the way).
See http://www.sqlite.org/lang_datefunc.html
If you need a pure Delphi value, just use a double column.
If you need some efficient timestamp, take a look at the TimeLog type for a column.

So the behavior on your table is perfectly as expected.
See the SAD pdf, in the "TSQLRecord fields" paragraph.

Offline

Board footer

Powered by FluxBB