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

[Sql Server] Add support for different integer sizes #1250

Closed
wants to merge 2 commits into from

Conversation

iluuu1994
Copy link

No description provided.

@@ -44,6 +44,12 @@ class SqlServerAdapter extends PdoAdapter implements AdapterInterface

protected $signedColumnTypes = ['integer' => true, 'biginteger' => true, 'float' => true, 'decimal' => true];

const INT_TINY = 255;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space found

@@ -44,6 +44,12 @@ class SqlServerAdapter extends PdoAdapter implements AdapterInterface

protected $signedColumnTypes = ['integer' => true, 'biginteger' => true, 'float' => true, 'decimal' => true];

const INT_TINY = 255;
const INT_SMALL = 65535;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space found

@@ -44,6 +44,12 @@ class SqlServerAdapter extends PdoAdapter implements AdapterInterface

protected $signedColumnTypes = ['integer' => true, 'biginteger' => true, 'float' => true, 'decimal' => true];

const INT_TINY = 255;
const INT_SMALL = 65535;
const INT_MEDIUM = 16777215;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space found

const INT_SMALL = 65535;
const INT_MEDIUM = 16777215;
const INT_REGULAR = 4294967295;
const INT_BIG = 18446744073709551615;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space found

if ($limit && $limit >= static::INT_TINY) {
$sizes = [
// Order matters! Size must always be tested from longest to shortest!
'bigint' => static::INT_BIG,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space found

$sizes = [
// Order matters! Size must always be tested from longest to shortest!
'bigint' => static::INT_BIG,
'int' => static::INT_REGULAR,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space found

'bigint' => static::INT_BIG,
'int' => static::INT_REGULAR,
'mediumint' => static::INT_MEDIUM,
'smallint' => static::INT_SMALL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space found

'int' => static::INT_REGULAR,
'mediumint' => static::INT_MEDIUM,
'smallint' => static::INT_SMALL,
'tinyint' => static::INT_TINY,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space found

@@ -44,6 +44,12 @@ class SqlServerAdapter extends PdoAdapter implements AdapterInterface

protected $signedColumnTypes = ['integer' => true, 'biginteger' => true, 'float' => true, 'decimal' => true];

const INT_TINY = 255;
const INT_SMALL = 65535;
const INT_MEDIUM = 16777215;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space found

@codecov-io
Copy link

codecov-io commented Dec 4, 2017

Codecov Report

Merging #1250 into master will increase coverage by 2.05%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1250      +/-   ##
==========================================
+ Coverage   72.32%   74.38%   +2.05%     
==========================================
  Files          35       35              
  Lines        5551     4744     -807     
==========================================
- Hits         4015     3529     -486     
+ Misses       1536     1215     -321
Impacted Files Coverage Δ
src/Phinx/Db/Adapter/SqlServerAdapter.php 0% <0%> (ø) ⬆️
src/Phinx/Migration/AbstractTemplateCreation.php 73.33% <0%> (-4.45%) ⬇️
src/Phinx/Console/Command/Breakpoint.php 36% <0%> (-3.29%) ⬇️
src/Phinx/Seed/AbstractSeed.php 46.34% <0%> (-1.58%) ⬇️
src/Phinx/Console/Command/AbstractCommand.php 50.89% <0%> (-1.49%) ⬇️
src/Phinx/Console/Command/Test.php 24.13% <0%> (-0.87%) ⬇️
src/Phinx/Db/Table.php 95.87% <0%> (-0.37%) ⬇️
src/Phinx/Db/Adapter/AbstractAdapter.php 80.32% <0%> (-0.27%) ⬇️
src/Phinx/Db/Adapter/TablePrefixAdapter.php 79.54% <0%> (-0.07%) ⬇️
src/Phinx/Db/Table/ForeignKey.php 97.91% <0%> (-0.05%) ⬇️
... and 25 more

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 454238f...4ba2196. Read the comment docs.

@iluuu1994
Copy link
Author

Why does this happen? Is the SqlServerAdapter not tested in Travis?

@chinpei215
Copy link
Contributor

Thank you for your contribution. SqlServerAdapter seems to be not tested on Travis. And Appveyor seems to be not triggered.

That aside, I tested your patch on my local computer with sqllocaldb, but it didn't pass. Would it pass on your environment?

C:\var\contributing\phinx>vendor\bin\phpunit tests\Phinx\Db\Adapter\SqlServerAdapterTest.php
PHPUnit 5.7.25 by Sebastian Bergmann and contributors.

............................................EEEEE                                                                                                                                                                49 / 49 (100%)

Time: 47.38 seconds, Memory: 10.50MB

There were 5 errors:

1) Test\Phinx\Db\Adapter\SqlServerAdapterTest::testBigIntegerColumn
Undefined offset: 1

C:\var\contributing\phinx\tests\Phinx\Db\Adapter\SqlServerAdapterTest.php:771

2) Test\Phinx\Db\Adapter\SqlServerAdapterTest::testMediumIntegerColumn
PDOException: SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]The size (16777215) given to the column 'column1' exceeds the maximum allowed for any data type (8000).

C:\var\contributing\phinx\src\Phinx\Db\Adapter\PdoAdapter.php:134
C:\var\contributing\phinx\src\Phinx\Db\Adapter\SqlServerAdapter.php:283
C:\var\contributing\phinx\src\Phinx\Db\Table.php:628
C:\var\contributing\phinx\src\Phinx\Db\Table.php:716
C:\var\contributing\phinx\tests\Phinx\Db\Adapter\SqlServerAdapterTest.php:779

3) Test\Phinx\Db\Adapter\SqlServerAdapterTest::testSmallIntegerColumn
RuntimeException: The SqlServer type: "smallint" is not supported

C:\var\contributing\phinx\src\Phinx\Db\Adapter\SqlServerAdapter.php:967
C:\var\contributing\phinx\src\Phinx\Db\Adapter\SqlServerAdapter.php:385
C:\var\contributing\phinx\src\Phinx\Db\Table.php:219
C:\var\contributing\phinx\tests\Phinx\Db\Adapter\SqlServerAdapterTest.php:790

4) Test\Phinx\Db\Adapter\SqlServerAdapterTest::testTinyIntegerColumn
RuntimeException: The SqlServer type: "tinyint" is not supported

C:\var\contributing\phinx\src\Phinx\Db\Adapter\SqlServerAdapter.php:967
C:\var\contributing\phinx\src\Phinx\Db\Adapter\SqlServerAdapter.php:385
C:\var\contributing\phinx\src\Phinx\Db\Table.php:219
C:\var\contributing\phinx\tests\Phinx\Db\Adapter\SqlServerAdapterTest.php:800

5) Test\Phinx\Db\Adapter\SqlServerAdapterTest::testIntegerColumnLimit
Undefined offset: 1

@iluuu1994
Copy link
Author

@chinpei215 Thank you for testing! Yeah I was hoping that I could use the CI process and wouldn't have to set it up myself locally. I'll look at the issues and report back.

const INT_SMALL = 65535;
const INT_MEDIUM = 16777215;
const INT_REGULAR = 4294967295;
const INT_BIG = 18446744073709551615;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is is possible to declare those constants as strings? Sorry if I am wrong, but I guess INT_BIG would overflow in 32bit PHP, and if you want to use unsigned bigint, it would overflow even in 64bit PHP.

@iluuu1994
Copy link
Author

@chinpei215 I took this from the MysqlAdapter which does it in the same way.

@chinpei215
Copy link
Contributor

Oh I didn't know that. Sorry. Then I don't request changes in this PR.

@iluuu1994
Copy link
Author

@chinpei215 Oh that's fine 😄 We had several other issues and decided to write native queries in the migrations which is suboptimal but easier in our situation. Thus I'll have to fix these issues in my free time. I'll look at them as soon as possible.

@chinpei215
Copy link
Contributor

Thanks.

@dereuromark
Copy link
Member

@iluuu1994 Do you still want to add those?
Please resolve conflicts.

@iluuu1994
Copy link
Author

iluuu1994 commented Apr 11, 2020

Nope, I'm not using this library anymore. You're free to take over.

@iluuu1994 iluuu1994 closed this Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants