Comments (5)
I just tried using now()
as the default value, and it appeared to work correctly:
postgres=# create table tmp(x INTEGER,foo timestamp with time zone default now());
CREATE TABLE
postgres=# insert into tmp(x) values(0);
INSERT 0 1
postgres=# select * from tmp;
x | foo
---+-------------------------------
0 | 2014-07-31 14:05:58.407412+03
(1 row)
And in fact, I ran the command at 14:05 in my current time zone (UTC+3). Can you clarify how you determined the now()
was not a sufficient default?
from yesodweb.com-content.
Well, it works correctly and does what you expect when having a column with time zone. However, yesod (or persistent) creates a column without time zone for the type UTCTime.
test=# create table tmp(x INTEGER,foo timestamp without time zone default now());
CREATE TABLE
test=# insert into tmp(x) values(0);
INSERT 0 1
test=# select * from tmp;
x | foo
---+----------------------------
0 | 2014-07-31 15:07:31.461828
(1 row)
I ran this command at 15:07 in my current time zone (UTC+2). So this is not the UTC time in the table.
With now() at time zone 'utc'
everything works as expected and I get
test=# select * from tmp;
x | foo
---+----------------------------
0 | 2014-07-31 13:07:31.461828
(1 row)
In contrast to that, a time from getCurrentTime
in Haskell is always printed as UTC and persistent insert this into the database like that. Again, if you use a table with without timestamp
as the default configuration does, it inserts the UTC time with dropping the time zone.
> getCurrentTime >>= print
2014-07-31 13:12:58.708879 UTC
from yesodweb.com-content.
Ahh, right, I forgot about that. We're about to release persistent 2.0, which will fix this bug. In the meanwhile, you can use ZonedTime
instead of UTCTime
.
from yesodweb.com-content.
Thanks!
Just to make sure I understood you correctly:
persistent 2.0 will use timestamp with time zone
by default?
from yesodweb.com-content.
Yes.
from yesodweb.com-content.
Related Issues (20)
- Error following through with Form section HOT 3
- NULL=NULL is NULL in Postgres HOT 6
- Yesod Book 1.4 --> 1.6 HOT 3
- Broken Link in the Chapter on Persistent HOT 1
- persistent page. Couldn't match type `BaseBackend backend0' with `SqlBackend' HOT 4
- Variable not in scope: entityDefs :: [EntityDef] HOT 9
- Unable to install yesod dev libraries HOT 4
- Undocumented suggestion to use "ddump-splices" GHC option HOT 3
- backslash in ^ escaping example missing in on-line version HOT 2
- Corrections for 1.6 in wiki example are incomplete (getSubYesod)
- Julius example missing rawJS with newIdent
- yesodweb.com domain is probably misconfigured HOT 1
- Book example of Yesod.Auth.Email needs updating / needs further instructions HOT 3
- Include Getting Started Information HOT 3
- Remove yesod init since it is deprecated HOT 1
- Possible mismatch between text and code example HOT 1
- PersistField vs. PersistValue HOT 1
- Outdated environment-variables page HOT 2
- Yesod Typeclass docs incorrectly say "The default value of approot is ApprootRelative" HOT 2
- Missing language extensions and incorrect call to mkSave
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yesodweb.com-content.