Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fActiveRecord silently overrides some column defaults on insert #205

Open
alandsidel opened this issue Feb 3, 2014 · 1 comment
Open

Comments

@alandsidel
Copy link

For some reason, fActiveRecord is choosing to interpret and reimplement default values defined in the database.

For example, inserting a new record into a table with a TIMESTAMP column, where the default value for the column is declared as CURRENT_TIMESTAMP, through some mechanism, fTimestamp is getting involved in the transaction and replacing the default value with the current value of time().

This is problematic for two reasons:

  • TIMESTAMPS are accurate to the microsecond. At the least, microtime() should be called rather than time().
  • Time differences between one (or several) web front ends, and a single backend database, will result in incorrect timestamps -- timestamps that exist in the schema and have a default value precisely to avoid this issue, by always stamping with the (consistent) DB server time regardless of what time the client thinks it is.

Some way of disabling this behavior and allowing the DB to perform it's normal function WRT column defaults is desirable.

@alandsidel
Copy link
Author

Investigating this problem, the changes required are wide in scope, and not easily addressed. The use of date() and strtotime(), as well as time() instead of microtime(true) are prolific throughout the code.

In "fixing" these issues I ended up gutting a lot of functional (but useless to me) code, too much to bother commiting to github or sending a pull request.

I'm updating the ticket just to point out the additional problems discovered, and give some idea of the scope involved in fixing them. I replaced fTime, fDate, and fTimestamp, deleted fORMValidation and had to make modifications to.fActiveRecord, fDatabase, fFile, fORM, fORMDate, fRequest, and fValidation.

I consider the behavior of overriding the DB default values, and not supporting the full scope of a Timestamp field to be actual bugs, and am leaving the ticket open. I suppose it could be closed and marked "won't fix", but I'll leave that to you to decide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant