Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Cache] [PdoAdapter] Fix MySQL 1170 error (blob as primary key)#21323

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
akeeman wants to merge2 commits intosymfony:masterfromakeeman:patch-1
Closed

Conversation

@akeeman
Copy link
Contributor

QA
Branch?3.2
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?n/a
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

When using a Doctrine\DBAL\Connection to initialize the PdoAdapter, PdoAdapter::createTable tries to create a table using a blob field as primary key.This is not an option for MySQL, resulting in an exeption:Syntax error or access violation: 1170 BLOB/TEXT column 'item_id' used in key specification without a key length. This commit supplies a way to act like the non-Connection way creates the table does.

Sync up with the non-Connection way of creating a table.
$schema =newSchema();
$table =$schema->createTable($this->table);
$table->addColumn($this->idCol,'blob',array('length' =>255));
$table->addColumn($this->idCol,$types[$this->driver],array('length' =>255));

Choose a reason for hiding this comment

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

why not just'mysql' === $this->driver ? 'binary' : 'blog'

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I indeed mentioned the MySQL case explicitly. However,the section below differs from the schema, in the sense that none of the statements there define the id column as blob (expecting you mean blob, not blog). Mapping it like this should result in an id column type that matches up with those below.

Copy link
ContributorAuthor

@akeemanakeemanJan 17, 2017
edited
Loading

Choose a reason for hiding this comment

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

I must say that I don't really know why sqlite uses text, but as you wrote it, I hope you do ;). In case this should be varchar too, then sqlite should also use 'string'. Then I would say that something like'mysql' === $this->driver ? 'binary' : 'string' would be applicable, and I'll change thesqlite line too.

Choose a reason for hiding this comment

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

I took inspiration fromhttps://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L214

what matters is having a storage of 255 bytes, with collations/charset disabled

Copy link
ContributorAuthor

@akeemanakeemanJan 17, 2017
edited
Loading

Choose a reason for hiding this comment

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

Well, given that works I'd suggest to make the end result the same. Using the initially proposed mapping will result that, givendoctrine's type mapping. Still I don't know why col type text is needed for sqlite, but probably I've got some catching up to do concerning that...

So, I now propose to keep it like my initial proposition. What about you?

Choose a reason for hiding this comment

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

ok. could you please fix fabbot's failure? then we're done

@fabpot
Copy link
Member

Thank you@akeeman.

fabpot added a commit that referenced this pull requestJan 17, 2017
… key) (akeeman)This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes#21323).Discussion----------[Cache] [PdoAdapter] Fix MySQL 1170 error (blob as primary key)| Q             | A| ------------- | ---| Branch?       | 3.2| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | n/a| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aWhen using a Doctrine\DBAL\Connection to initialize the PdoAdapter, PdoAdapter::createTable tries to create a table using a blob field as primary key. [This is not an option for MySQL](https://techjourney.net/mysql-error-1170-42000-blobtext-column-used-in-key-specification-without-a-key-length/), resulting in an exeption: `Syntax error or access violation: 1170 BLOB/TEXT column 'item_id' used in key specification without a key length`. This commit supplies a way to act like the non-Connection way creates the table does.Commits-------08c6a65 [Cache] [PdoAdapter] Fix MySQL 1170 error (blob as primary key)
@fabpotfabpot closed thisJan 17, 2017
@akeemanakeeman deleted the patch-1 branchJanuary 18, 2017 07:45
@fabpotfabpot mentioned this pull requestFeb 6, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@akeeman@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp