-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add index length option for MySQL #68
Conversation
Conflicts: lib/SQL/Translator/Producer/PostgreSQL.pm
I like the idea, I'd be tempted to try and hide the fact that the fields may be either strings or hashrefs more... that is instead of having ref $_ ? everywhere, make a method field_names on the Index object which just returns the strings, and maybe another one fields_with_lengths, which returns names and/or name(size) strings as appropriate. That way if we at some point add more attrs or just make them all refs, we only change one place. |
@castaway thanks for looking - I agree with the please make a helper function part. @abeverley Recall how I was unsure about the name - after reading various manuals I am now pretty sure I am volunteering to do the renaming work (you've waited long enough on this PR) - I am just making sure you are not opposed to the changes (as you will need to reflect them on your end :/) |
@ribasushi got it, thanks for the update! |
On Wed, 2015-11-04 at 06:14 -0800, Peter Rabbitson wrote:
Not at all, absolutely fine.
Fantastic, thanks. Andy |
On Wed, 2015-11-04 at 03:12 -0800, castaway wrote:
Thanks @castaway, makes sense. I don't want to hold a release up though, Thanks, Andy |
@castaway Leaving the part @abeverley requested to you unless I hear otherwise... |
@abeverley @ribasushi yes, can do (tho @ribasushi may have to remind me of the best way to add to/update the PR) |
@castaway Don't worry about proper GitHub etiquette (as if such a thing ever existed). Get his changes in some form, mangle them, then push a branch of your own naming to the main repo. I will pick it up from there. |
Fixes pushed to branch on my github clone with same name.. (and @ribasushi poked with it) |
Codecov Report
@@ Coverage Diff @@
## master #68 +/- ##
==========================================
+ Coverage 21.5% 21.57% +0.06%
==========================================
Files 71 71
Lines 19914 19930 +16
Branches 5728 5741 +13
==========================================
+ Hits 4283 4299 +16
+ Misses 14922 14921 -1
- Partials 709 710 +1
Continue to review full report at Codecov.
|
I've just realised that I don't think this ever got merged. I realised by building a new dev machine and finding the use of this feature not working, so would be good to prevent that happening again in the future ;-) Would it be possible to merge it please? I've merged in @castaway's changes as discussed above and fixed some merge conflicts. Thanks! |
This commit fixes a bug whereby index lengths (normally only used in MySQL) were not being produced by the YAML producer. This matters, as sometimes YAML is used to produce diffs of schema changes (e.g. DBIC Migration) and before this commit diffs of indexes were not working correctly.
@rabbiveesh - I understand that you have recently taken over this module. Would there be any chance of merging this long-standing PR please? I have updated it to allow merging with the latest version of master. I have to keep patching my installations, so would appreciate it being in the CPAN release! Many thanks. |
@rabbiveesh @nrdvana ping - any chance of merging this please? I've just rebased to master again, which takes a while each time I have to do it, so would be grateful not to have to do it again :-) Thanks. |
@rabbiveesh As you design that, an interesting unit test for postgres to really test the boundaries would be
:-) |
Can you put this on the other ticket? |
Well, to spell out the thought I had, the column of an index isn't always a column; it could be a function. And there could be two functions of the same column, so the unique check probably needs to be removed. And (I still didn't check this) if existing parsers are returning sql expressions as the 'field' currently, then the thing that the object returns when stringified should probably be an attribute named something like 'original_sql_expr' instead of 'name'. Quoting the name in a producer should probably only happen if it is known to be a simple name. And all these things probably need to be thought about now in order to make the postgres parser/producer reasonable to implement. |
I think that the design we settled on is sufficiently encapsulated that we can make changes later. re |
The truth is, using expressions as index fields would actually need it's own support completely, b/c it would break the very naive We should write up all these notes in a new ticket (hint hint) |
Fine, i opened the other ticket |
@abeverley I have opened the PR abeverley#1 with my changes. Please review it w/ your thoughts and/or add to its completeness. If you could add the |
Ah, I just saw this comment after posting my other one. I will merge your changes and then add the key as suggested. |
Okay, I've just done that (bfc7565). I've only done it in the YAML producer, as the JSON one seems to be structured differently and doesn't return a list of fields. I noticed that I didn't touch the JSON producer originally, possibly because of that limitation. The YAML producer was changed in this commit (4a06a63) - I am not sure if that should also be applied to the JSON producer? |
Super sorry that I've dropped the ball on this one. Where are we holding? |
No problem at all. Personally I think it is all good to go. I've used your revised implementation (much better), made some minor updates and fixed the tests. The only thing I haven't done is update the JSON producer, but that's because it seems to not be applicable so there is nothing to update. Let me know if you disagree :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm gonna do the last touches here
@abeverley made a PR against your PR again, merge it up + we're good to go over here |
Finish up the index length PR
Awesome! So i'll merge this up, and do a dev release, I hope to get around to implementing the parser side of this feature and then we can do a real release |
Brilliant, thanks @rabbiveesh - really pleased we've got this merged now. It was definitely worth spending a bit of time on it. As a final test I've just tried it on my local code base and I can confirm it works as expected. |
This adds an option to be able to specify index lengths for MySQL, such as:
$index->fields( 'id', { name => 'firstname', size => 15 } );
The majority of this PR is updating the other providers to ignore this, and a bunch of tests (including a new basic SQLServer test).