Skip to content

fix text and char column php code args #40

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

Merged
merged 1 commit into from
Feb 9, 2023

Conversation

cfebs
Copy link
Contributor

@cfebs cfebs commented Feb 9, 2023

#39 started setting character_set and collation properties which surfaced a problem that already existed in src/Schema/Column/TextTrait.php

A leading comma would be added to the generated constructor:

? ', \'' . $this->character_set . '\'' . ', \'' . $this->collation . '\''

Also noticed a potential bug in #39 in CharacterColumn arg building:

return '(new \\' . static::class . '('
. $this->max_string_length
. ($this->character_set !== null ? ', \'' . $this->character_set . '\'' : '')
. ($this->collation !== null ? ', \'' . $this->collation . '\'' : '')
. '))'
. $default
. $this->getNullablePhp();

If only collation was defined in that implementation, the value of collation would be used for the character_set argument in the constructor

This PR:

  • just use a simple implode to always pass the number of args for CharacterColumn or TextColumn
  • add a test table with each permutation of test and varchar CHARACTER SET and COLLATE

charset and collation should be both optional on a column definition
@cfebs cfebs requested review from aaronm67 and muglug February 9, 2023 22:59
@cfebs cfebs merged commit 1b71076 into vimeo:master Feb 9, 2023
@cfebs cfebs deleted the cl-fix-text-nomax branch February 9, 2023 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants