[6.x] Postgresql column precision declaration fix#29873
Conversation
|
@chmv heya. Thanks for your first pr. Can you maybe also add some tests for these changes? |
|
@staudenmeir any chance you can have a look at this? Thanks! |
I'll try. How to send changes in the right way? Do I need to make a new pr or is there a way to add to this? Thank you! |
|
@chmv you can push commits onto your branch and they'll be added to this pr. |
|
@driesvints Thanks! Done. |
|
Looks good to me. I think it would be easier to read if we switch the two sides: (isset($column->precision) ? "($column->precision)" : '') |
|
I'm not sure if this is rightly. Of course, it's really more beautiful. My first variant was (! is_null ...), but it's ugly, so I switched it. But isset... There is an unexpected default value of 0... in other method... It might confuse someone... |
Hello!
Briefly:
Allows you to create columns without optional precision:
"column1" timestamp WITHOUT TIME zone NOT NULL,In detail:
Now there is no way to create Date/Time column with undefined precision as described in 8.5.1:
https://www.postgresql.org/docs/11/datatype-datetime.html#DATATYPE-DATETIME-INPUT
For example this code:
will create this sql request:
There is no way to get rid of (0) in a SQL query. Because of 0 as a default value:
public function timestamp($column, $precision = 0)In this patch, null precision can be specified.
in result:
Full backward compatibility. Since the previous behavior generated an invalid SQL query in this case.
Thank you!
P.S. This is my first pull request. Please correct me if I made a mistake. Thanks.