CareSet / DURC

DURC is reverse CRUD
MIT License
3 stars 2 forks source link

"none" dates crash the compiler #53

Closed ftrotter closed 4 years ago

ftrotter commented 4 years ago

When choosing from datetime option fiields in DURC if you choose "none" in phpyadmin it zeros out the date field.

When DURC creates the syntax for this default it includes single quotes inside the single quotes for the php variable and breaks the php syntax. So its like:

$var_date = ''00:00:00 etc etc''; where it should generate $var_date = '00:00:00 etc etc';

This crashes compilation of DURC:write and is a show stopping bug

kchapple commented 4 years ago

@ftrotter What PHP file (model, controller, function, etc.) was the malformed PHP generated in? I'm not able to reproduce this error using the following schema, where datetime_none and date_none columns use phpmyadmin's "none" option as default like this:

Screen Shot 2020-04-09 at 10 42 15 AM

Here's the schema that was generated:

CREATE TABLE test_default_date ( id int(11) NOT NULL, datetime_none datetime NOT NULL, date_none date NOT NULL, datetime_current datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, date_current varchar(255) DEFAULT 'Current timestamp not supported for date', datetime_null datetime DEFAULT NULL, date_null date DEFAULT NULL, datetime_defined datetime NOT NULL DEFAULT '2000-01-01 01:23:45', date_defined date NOT NULL DEFAULT '2000-01-01' ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE test_default_dates ADD PRIMARY KEY (id);

kchapple commented 4 years ago

I did find other errors related to dates and defaults that I am looking at.

kchapple commented 4 years ago

@seanccsmith I think I may have found and fixed this, as I came across it in my testing another issue today, but haven't tested Fred's specific case though.

seanccsmith commented 4 years ago

Confirmed, the compiler no longer crashes when date fields are None by default. Closing issue.