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

Improve documentation around ancestry field and collation #607

Merged
merged 2 commits into from
Mar 3, 2023

Conversation

kbrock
Copy link
Collaborator

@kbrock kbrock commented Mar 1, 2023

dependency:

postgres: binary data type is not currently working
mysql: binary data type or string with binary collation is working

Had wanted to go with a binary for all database, but the test would not pass.
So I backtracked a little, researched opclasses, preferring ascii where possible.

This updates the comments introduced in #601

@kbrock kbrock mentioned this pull request Mar 1, 2023
4 tasks
@kbrock
Copy link
Collaborator Author

kbrock commented Mar 1, 2023

@kshnurov I updated the gem to use binary for postgres. The test suite puked.

Staying with the original comments, but put in more documentation to hopefully get this running correctly.

@kshnurov
Copy link
Contributor

kshnurov commented Mar 1, 2023

@kshnurov I updated the gem to use binary for postgres. The test suite puked.

Ok, after some digging it turns out postgres returns bytea in hex format and pg gem doesn't unescape it by default.
Here's a quick solution for postgres, it should also solve this

ALTER DATABASE dbname SET bytea_output to 'escape';

With this one, tests are green unless we use update_strategy = :sql.
regexp_replace isn't possible with binary columns. I'd suggest removing :sql update strategy completely.

Another solution is to call connection.unescape_bytea on ancestry field, but I don't wanna dig into it since I'm using mysql right now.

@kbrock kbrock force-pushed the more_collation_documentation branch from c5de07d to c1a253c Compare March 2, 2023 03:01
@kbrock
Copy link
Collaborator Author

kbrock commented Mar 2, 2023

@kshnurov For a binary ancestry column, what else do I need to specify to set a length? And what value should I use?

 Mysql2::Error: BLOB/TEXT column 'ancestry' used in key specification without a key length (ActiveRecord::StatementInvalid)

@kshnurov
Copy link
Contributor

kshnurov commented Mar 2, 2023

For a binary ancestry column, what else do I need to specify to set a length? And what value should I use?

IDK if you missed this comment
It definitely shouldn't be a BLOB.

@kbrock kbrock force-pushed the more_collation_documentation branch from c1a253c to 1d62cd4 Compare March 2, 2023 19:16
Since this is used in all tests, best to cache this
@kbrock kbrock force-pushed the more_collation_documentation branch from 1d62cd4 to 394ff38 Compare March 3, 2023 04:18
postgres: binary data type is not currently working
mysql: binary data type or string with binary collation is working

Had wanted to go with binary for all, but test would not pass
@kbrock kbrock force-pushed the more_collation_documentation branch from 394ff38 to 18ad23e Compare March 3, 2023 04:24
@kbrock
Copy link
Collaborator Author

kbrock commented Mar 3, 2023

update:

  • provided simplified column information and a section with probably way too much detail. After time, this can probably be simplified.
  • Added details about using/preferring materialized_path2
  • Added configuration file step to default to materialized_path2

@kbrock kbrock merged commit ede43a2 into stefankroes:master Mar 3, 2023
@kbrock kbrock deleted the more_collation_documentation branch March 3, 2023 04:27
kbrock added a commit to kbrock/ancestry that referenced this pull request Mar 3, 2023
* Fix: descendants ancestry is now updated in after_update callbacks stefankroes#589
* Document updated grammar stefankroes#594
* Documented `update_strategy` stefankroes#588
* Fix: fixed has_parent? when non-default primary id stefankroes#585
* Documented column collation and testing stefankroes#601 stefankroes#607
* Added initializer with default_ancestry_format stefankroes#612
* ruby 3.2 support stefankroes#596
kbrock added a commit to kbrock/ancestry that referenced this pull request Mar 3, 2023
* Fix: materialized_path2 strategy stefankroes#597
* Fix: descendants ancestry is now updated in after_update callbacks stefankroes#589
* Document updated grammar stefankroes#594
* Documented `update_strategy` stefankroes#588
* Fix: fixed has_parent? when non-default primary id stefankroes#585
* Documented column collation and testing stefankroes#601 stefankroes#607
* Added initializer with default_ancestry_format stefankroes#612
* ruby 3.2 support stefankroes#596
kbrock added a commit to kbrock/ancestry that referenced this pull request Mar 4, 2023
* Fix: materialized_path2 strategy stefankroes#597
* Fix: descendants ancestry is now updated in after_update callbacks stefankroes#589
* Document updated grammar stefankroes#594
* Documented `update_strategy` stefankroes#588
* Fix: fixed has_parent? when non-default primary id stefankroes#585
* Documented column collation and testing stefankroes#601 stefankroes#607
* Added initializer with default_ancestry_format stefankroes#612
* ruby 3.2 support stefankroes#596
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