-
-
Notifications
You must be signed in to change notification settings - Fork 241
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
Fix Anko converter #218
Fix Anko converter #218
Conversation
Fixes #217
fix/anko.go
Outdated
// skip already converted create_table | ||
if strings.Contains(line, ", func(t) {") { | ||
// fix create_table | ||
line = strings.Replace(line, ", func(t) {", ") {", -1) |
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.
Since you are re-doing this, it would be nice to use regex.ReplaceAllString() so that it'll not care about any whitespace. (We didn't have , func
, but ,func
and it wouldn't work.
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.
Done. :)
fix/anko.go
Outdated
i++ | ||
line = lines[i] | ||
tl = strings.TrimSpace(line) | ||
if l == i { |
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.
you are checking for overflow after trying to access an item past the length of the array on 38.
t.Column("id","uuid",{"primary":true}) | ||
} | ||
) |
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 clearly just missing it since the tests are passing, but at some point you are going to have to explain to me how it's catching this straggler seeing as it looks to me as though it would have moved out of the create_table logic the line before.
Thanks for changing that to a RegEx btw^^ |
@mclark4386 I've fixed the overflow check and added more details. :) |
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.
Perfect! Thanks!
fix/anko.go
Outdated
// Now, we have to make sure to match the missing ")" | ||
waitParen = true | ||
} else if waitParen && strings.HasPrefix(tl, ")") { | ||
break |
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.
Need to clear line before breaking and then we are good!
fix/anko.go
Outdated
@@ -30,12 +30,13 @@ func Anko(content string) (string, error) { | |||
waitParen := false | |||
for { | |||
if strings.HasPrefix(tl, "})") { | |||
line = "}" | |||
line = tl[2:] |
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.
in the case that tl is "})" then tl[2:] will be "". I think you were going for "}" + tl[2:]
Fixes #217