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

Fix mysql parse default b'0' #1584

Merged
merged 1 commit into from Jun 11, 2017

Conversation

trevorsibanda
Copy link
Contributor

#1268

Possible tweak might be to combine the two regexp for match BooleanPattern and BitPattern into one

Maybe

^(?:([01])|((?:b')([01])(?:')))

@d6y d6y added the 2 - Working label Aug 1, 2016
@cvogt
Copy link
Member

cvogt commented Aug 1, 2016

nice :)!! As always, test would be great ;)

@@ -80,6 +80,17 @@ val SimpleA = CustomTyping.SimpleA
})
},
new UUIDConfig("CG10", StandardTestDBs.H2Mem, "H2Mem", Seq("/dbs/uuid-h2.sql")),
new Config("MySQL", StandardTestDBs.MySQL, "MySQL", Seq("/dbs/mysql.sql")){
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cvogt Whats wrong with this test?

Copy link
Member

Choose a reason for hiding this comment

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

actually looks great. Overlooked that somehow. Great.

Copy link
Member

Choose a reason for hiding this comment

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

seem like it is failing on travis though? can it be anything like the version, some mysql configuration, the environment (os, 64/32 bit, etc)?

@cvogt cvogt added this to the 3.2.0 milestone Aug 2, 2016
else l
override def length: Option[Int] = super.length match{
case Some(l) if varying && l >= 65535 => None
case l => l
Copy link
Member

Choose a reason for hiding this comment

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

not a big deal. but the idiomatic way to do this would be super.length.filter(!varying || _ < 64435)

@cvogt
Copy link
Member

cvogt commented Aug 8, 2016

How does 772fa7b fix the test failure?

@trevorsibanda
Copy link
Contributor Author

@cvogt I had previously used reference equality check so switched to == instead.

v eq "1" to v == "1"

@trevorsibanda
Copy link
Contributor Author

@cvogt Is there anything I should change here ?

@trevorsibanda
Copy link
Contributor Author

@cvogt What should I change here ?

case ("1","Boolean") => Some(Some(true))
case ("0","Boolean") => Some(Some(false))
case ( BooleanPattern(v) , "Boolean") => Some( Some(v == "1"))
case ( BitPattern(v) , "Boolean") => Some( Some( v == "1"))
Copy link
Member

@cvogt cvogt Aug 16, 2016

Choose a reason for hiding this comment

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

may be simpler:

 case ( "0" | "b'0'", "Boolean" ) => Some( Some(false) )
 case ( "1" | "b'1'", "Boolean" ) => Some( Some(true) )

(and maybe even more correct because the regexes didn't use a trailing $, which mean BooleanPattern may have matched 12345 as true, not only 1).

@trevorsibanda
Copy link
Contributor Author

@cvogt this is ready. Travis CI tests timing out... problem with Oracle

@trevorsibanda
Copy link
Contributor Author

@cvogt this is ready

if(tpe == "String" && varying && l == Some(65535)) None
else l
}
override def length: Option[Int] = super.length.filter(_ => !varying || dbType == Some("VARCHAR"))
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain this change? Just trying to understand the implications :). Ideally anything you found out about the old code here and what the implications of the new code are / what it fixes. Ideally this would be in the commit message, so future contributors can find it using git blame.

else if(l.length <= 16777215 ) "MEDIUMTEXT"
if(l.length < 65535 ) s"VARCHAR(${l.length})"
else if(l.length >= 65535 && l.length < 16777215) "TEXT"
else if(l.length <= 16777215) "MEDIUMTEXT"
Copy link
Member

Choose a reason for hiding this comment

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

Why exclude the 65535 case from VARCHAR? MEDIUMTEXT now only seems to be used for length exactly = 16777215. Was that intended?

if(l.length <= 65535 ) s"VARCHAR(${l.length})"
else if(l.length <= 16777215 ) "MEDIUMTEXT"
if(l.length < 65535) s"VARCHAR(${l.length})"
else if(l.length == 65535) "TEXT"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

mysql jdbc driver sets type TEXT to length 65535. Setting TEXT for length 65535 is safer since there is a row size limit .

[error] Test slick.test.codegen.GeneratedCodeTest.allTests failed: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs, took 51.986 sec

@szeiger szeiger modified the milestones: 3.2.0, 3.2.1 Feb 8, 2017
@trevorsibanda
Copy link
Contributor Author

@cvogt can you take a look at this

@cvogt
Copy link
Member

cvogt commented Jun 10, 2017

LGTM!

@trevorsibanda trevorsibanda merged commit 58ba04e into slick:master Jun 11, 2017
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.

None yet

5 participants