#802 ✓resolved
Simon Rozet

Unspecified size of URI type cause error on MySQL

Reported by Simon Rozet | February 16th, 2009 @ 05:32 AM | in 0.10.0

Hey guys, Someone reported this on Integrity's LH :

mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (x86_64) using readline 5.2

The query and error is

/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.10/lib/dm-core/adapters/data_objects_adapter.rb:92:in execute_non_query': (mysql_errno=1064, sql_state=42000) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT NULL,branchVARCHAR(50) DEFAULT 'master',commandVARCHAR(50) DEFAU' at line 1 (MysqlError)

Query: CREATE TABLE integrity_projects (id serial PRIMARY KEY, name VARCHAR(50), permalink VARCHAR(50), uri VARCHAR DEFAULT NULL, branch VARCHAR(50) DEFAULT 'master', command VARCHAR(50) DEFAULT 'rake', public TINYINT DEFAULT 1, building TINYINT DEFAULT 0, created_at DATETIME, updated_at DATETIME, build_id INT(11), notifier_id INT(11)) from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.10/lib/dm-core/adapters/data_objects_adapter.rb:92:in execute'

Running the query on the command line reveals that uri VARCHAR DEFAULT NULL is causing the problem.

Looks like a value is needed for the VARCHAR

Might be related to #591, I don't know.

Feel free to ping me on #datamapper (I am sr) if there is anything I can do to help.

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) February 21st, 2009 @ 03:05 AM

    • Assigned user set to “Michael Klishin (antares)”
    • State changed from “unconfirmed” to “confirmed”

    @Michael: it appears as if the URI type doesn't have a length specified and it is causing an issue with MySQL.

    I've used this type alot of times with SQLite3 in specs, and I can't recall any issues.

    I was thinking the reason for this was probably due to a misunderstanding how the primitive option works. I believe the original author thought it would pull in the defaults for the String primitive and use them. Even though this isn't how things work now, I believe it is how they should work.

    In the future the DM::Types and DM::Property objects are going to be fused, as you know, and the URI object would inherit from String, taking on all of it's constraints and defaults.. one of those being that a String has a default length of 50. Of course 50 is probably too short for a URI, but at least it wouldn't cause an explosion when used.

    Do you or anyone else have a suggestion for a default URI length? Anything up to 255 is ok, but we usually like to have a good reason to go beyond because on some storage engines it imposes undesirable limitations.

  • Stephen Eley

    Stephen Eley February 24th, 2009 @ 05:18 PM

    • Tag changed from dm-types to dm-types, uri

    255, based on the recommended length limitation in RFC 2068. That's about as official an answer as you could get on something like this.

    I found this Lighthouse issue from hitting the same length limitation in Integrity, BTW. I'm a little shocked to find out along the way that strings in DataMapper are artificially constrained to an annoyingly small value if I don't specify a length. I just assumed they were always 255. I don't recall any documentation on this in the Datamapper Wiki.

    Is there any easy way to override this default? I don't use those storage engines that "impose undesirable limitations," and for most common RDBMS systems there's no real storage or performance benefit to putting length limitations on varchars. Just headaches to users like me when things break or get truncated on limits we didn't know about.

  • Michael Klishin (antares)

    Michael Klishin (antares) March 26th, 2009 @ 05:21 PM

    • Milestone set to 0.10.0
    • State changed from “confirmed” to “accepted”

    On my short list now. I am less proficient with MySQL than with Postgres, but I understand where to start looking. Thanks for explanation.

  • Michael Klishin (antares)

    Michael Klishin (antares) March 28th, 2009 @ 12:26 AM

    • State changed from “accepted” to “resolved”

    It turns out Steven already fixed this in 13bbcc8592.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »