Postgresql, timestamp and EF

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
damon.cognito
Posts: 50
Joined: Wed 22 Jul 2009 09:30

Postgresql, timestamp and EF

Post by damon.cognito » Tue 09 Jun 2015 13:49

I've noticed that EF does not seem to handle the precision of a PostgreSQL timestamp. If you have a 'timestamp(x) with time zone' (where x is 0 to 6) this is imported as a 'timestamp with time zone'. This does cause some issues when the field is marked as concurrency mode, but the main issue is when we use the 'create script from model' option, it returns the wrong type of timestamp. A simple test database follows:

Code: Select all

CREATE DATABASE test WITH TEMPLATE = template0 ENCODING = 'LATIN1' LC_COLLATE = 'C' LC_CTYPE = 'C';

Code: Select all

-- Dumped from database version 9.3.5
ALTER DATABASE test OWNER TO postgres;

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'LATIN1';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

CREATE DATABASE test WITH TEMPLATE = template0 ENCODING = 'LATIN1' LC_COLLATE = 'C' LC_CTYPE = 'C';
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';

SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;

CREATE TABLE atable (
    column1 timestamp with time zone,
    column2 timestamp(0) with time zone
);
ALTER TABLE public.atable OWNER TO postgres;

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
Regards, Damon.

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: Postgresql, timestamp and EF

Post by Shalex » Fri 12 Jun 2015 17:03

Thank you for your report. We are processing your request.

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: Postgresql, timestamp and EF

Post by Shalex » Mon 15 Jun 2015 12:48

damon.cognito wrote:If you have a 'timestamp(x) with time zone' (where x is 0 to 6) this is imported as a 'timestamp with time zone'.
We have reproduced the case and are investigating the question.
damon.cognito wrote:This does cause some issues when the field is marked as concurrency mode
We have just sent a test project to the email address specified in your forum profile. The concurrency mode with a property which corresponds to the 'timestamp(6) with time zone' column works as expected. Please modify it for reproducing the bug and send it back to us.

damon.cognito
Posts: 50
Joined: Wed 22 Jul 2009 09:30

Re: Postgresql, timestamp and EF

Post by damon.cognito » Tue 23 Jun 2015 22:38

This has been done. Cheers!

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: Postgresql, timestamp and EF

Post by Shalex » Thu 02 Jul 2015 14:57

The behaviour is changed in the new (7.3.447) build of dotConnect for PostgreSQL: now Entity Developer and EDM Wizard take into account precision of the timestamp columns in Model First / Database First approaches.

Post Reply