Field declaration property diferences between Nullable and Not

TDados = Class [Column("Nome_Cli")] FNome : string; -> this field has defined with null in my table of database Fcodigo: integer; end;

client : tdados;

cliente.codigo = 1;

in the case of property FNome , this will save NULL in table?, one time i not referenced in the object client, or need define e.g: FNome? have any problem? ``` type or paste code here ```

Sorry, but your message got really confusing. Text is unformatted, it's hard to understand.

To save null in database, you have to use Nullable<T> types. In some databases, empty string is the same as null, so in those cases it might be that the empty string will result in NULL value in database.

sorry. Can I use it without null and not pass the value to the property that will have the same effect, will it save null in the database?

i'm using firebird 2.5

I tested with the following:

client.nome = '' without spaces -> aurelius saves null in the table( as expected )
client.nom = ' ' -> with spaces -> saves not null, because i passed string with spaces( correct )

if that is fine for me, because i cam use without nullable for avoid exception variant convertion in delphi

No problem. Just be aware that it's not "Aurelius" that saves null in the table. It's the database. For different databases, the behavior might not be the same.

1 Like

many thanks!

Just to clarify that this behavior it's not really from the database (Firebird) but the driver/connection components used (FireDac?). Firebird do not change empty strings into nulls, they are distinct "values".


This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.