When I'm installing/enabling the External RDF Vocabulary Importer module, and it attempts to do an initial import of a few namespaces I get a full screen of errors. I'm using MySQL 5.1 and it appears to be a problem with the range field.

user warning: 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 'range) VALUES ('dc', 'title', 'Title', 'A name given to the resource.', '', '')' at line 1 query: INSERT INTO drupal_evoc_rdf_properties (prefix, id, label, comment, domain, range) VALUES ('dc', 'title', 'Title', 'A name given to the resource.', '', '') in /drupal/includes/common.inc on line 3422.

This record is inserted with drupal_write_record, so I'm not sure what could be done other than rename the field? If fields were surronded by `` in dwr then things work fine.

CommentFileSizeAuthor
#5 evoc-reserved-word-rename.patch2.51 KBfebbraro

Comments

scor’s picture

so this might a bug in the drupal_write_record core function. There is a related issue at #266610: Function drupal_write_record() should enclose field names by backticks but it is currently "won't fix".

febbraro’s picture

I think you are likely right here, but not sure what to do about that.

What I did to get the functionality to work was I renamed the field 'range' (and all references to it) to rdf_range and it all worked great. Any chance you would agree with renaming to make it work on MySQL 5.1? If you think it is a good idea, just tell me the names you want I would gladly provide the patch that does the renaming.

febbraro’s picture

I think you are likely right here, but not sure what to do about that.

What I did to get the functionality to work was I renamed the field 'range' (and all references to it) to rdf_range and it all worked great. Any chance you would agree with renaming to make it work on MySQL 5.1? If you think it is a good idea, just tell me the names you want I would gladly provide the patch that does the renaming.

scor’s picture

that's lame (drupal_write_record) but I don't see a work around. go ahead with rdf_domain and rdf_range then.

febbraro’s picture

Status: Active » Needs review
StatusFileSize
new2.51 KB

Give this a review, let me know if you have any feedback

krao’s picture

Friend thanks for the patch, I was working properly.

scor’s picture

Status: Needs review » Fixed

fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mswimmer’s picture

It might be a good idea to make this patch permanent. In MySQL 5.1 the keyword 'range' is a reserved word (http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-refe...) and drupal doesn't put quotes around the column names when accessing them. This means that any SQL query with range in it will fail with an error. The patch does work, though I hope that Drupal starts putting column names in quotes as this would be safer.

scor’s picture

@mswimmer: I suppose you're talking about Drupal's API functions in general? You're right, though with PHP PDO in Drupal 7, things have changed for the better so this should not be a problem anymore.