cycle / database

Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders
MIT License
54 stars 24 forks source link

Cast postgresql char column size to int #34

Closed rauanmayemir closed 2 years ago

rauanmayemir commented 2 years ago

This is helpful when being used with PDO::ATTR_STRINGIFY_FETCHES. Turns out, every other driver correctly casts the int values.

codecov[bot] commented 2 years ago

Codecov Report

Merging #34 (8690916) into 2.x (125b66d) will decrease coverage by 0.02%. The diff coverage is 100.00%.

:exclamation: Current head 8690916 differs from pull request most recent head ef9f29b. Consider uploading reports for the commit ef9f29b to get more accurate results Impacted file tree graph

@@             Coverage Diff              @@
##                2.x      #34      +/-   ##
============================================
- Coverage     92.81%   92.78%   -0.03%     
- Complexity     1521     1523       +2     
============================================
  Files            93       93              
  Lines          3937     3936       -1     
============================================
- Hits           3654     3652       -2     
- Misses          283      284       +1     
Impacted Files Coverage Δ
src/Driver/Postgres/Schema/PostgresColumn.php 91.36% <100.00%> (ø)
src/Driver/MySQL/MySQLDriver.php 95.65% <0.00%> (-4.35%) :arrow_down:
src/Config/DatabaseConfig.php 97.29% <0.00%> (-2.71%) :arrow_down:
src/Driver/Driver.php 87.37% <0.00%> (+0.39%) :arrow_up:
src/Driver/Postgres/Schema/PostgresTable.php 94.73% <0.00%> (+0.45%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 125b66d...ef9f29b. Read the comment docs.

roxblnfk commented 2 years ago

Can you add test for this case?

rauanmayemir commented 2 years ago

How would I test this and what’s the point?

If anything, this fixes an indirection where you are checking casted int in the IF condition but then assigning it without the cast.

rauanmayemir commented 2 years ago

Added a new tests suite for a postgres config with custom PDO settings. Currently, tests are failing on pgsql10 due to a foreign key columns order difference.

I doubt it's related to my change, but will need to check it properly.