Change database data type for date

Posts   
 
    
methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 23-May-2018 11:18:04   

Hi,

I'd like to change the default SQL data type for date from 'date' to 'timestamp' in the generated SQL. Is this possible ?

Database: PostgreSql Version 4.2

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 23-May-2018 11:39:35   

the .NET type DateTime should now be mapped to a timestamp by default?

Frans Bouma | Lead developer LLBLGen Pro
methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 23-May-2018 11:46:31   

Just for my project simple_smile The problem is I'm using Oracle and PostgreSql for the same application.

Oracle stores date + time in date Postgre store only date in date, but timestamp stores date + time.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 23-May-2018 12:06:29   

For database first, it maps timestamp already to DateTime for postgresql, so you're looking for the modelfirst variant I recon?

You can do that by altering the driver sourcecode, and as v4.2 won't receive new updates that's not a problematic issue. In Postgresqldbdriver.cs line 231, you'll see the rules for datetime, where Date is the first choice. Switch the line with the one with Timestamp, compile it (change the strong key in assembly info) and the DateTime type should now result in Timestamp fields in the DB.

A type converter won't work here as Timestamp already resolves to DateTime.

In v5.x you can specify the default type so that would solve it without altering the driver.

Frans Bouma | Lead developer LLBLGen Pro
methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 23-May-2018 12:37:38   

Thank you