csv2sql icon indicating copy to clipboard operation
csv2sql copied to clipboard

MySQL error when running the application for the first time.

Open Arp-G opened this issue 4 years ago • 0 comments

When running the application sometimes MySQL gives an error like:

%MyXQL.Error{connection_id: 9, message: "(1067) (ER_INVALID_DEFAULT) Invalid default value for 'DateModified'", 
mysql: %{code: 1067, name: :ER_INVALID_DEFAULT}, statement: "CREATE TABLE csvsql_test.ActivityStream (`ItemId` VARCHAR(100), 
`ItemVersion` BIT, `_ItemTimestamp` VARCHAR(100), `ActivityStreamType` INT, `OriginalValue` TEXT, `NewValue` VARCHAR(100), 
`CreatorId` VARCHAR(100), `DateCreated` TIMESTAMP, `ModifierId` VARCHAR(100), `DateModified` TIMESTAMP, `OwnerId` VARCHAR(100));"}

Surprisingly this error disappears most of the time, and the app works fine when stopped and started again just after the error occurs.

As evident from the error message, it has something to do with default values for timestamp columns.

I suspect setting some MySQL modes might have something to do with this error. However, I am not sure, since this error occurs randomly even when testing with the same CSV files.

SET GLOBAL SQL_MODE="NO_BACKSLASH_ESCAPES,NO_ENGINE_SUBSTITUTION,NO_ZERO_IN_DATE";

MySQL docs, regarding the NO_ZERO_IN_DATE mode.

Arp-G avatar Oct 18 '20 14:10 Arp-G