Merge lp:~jkakar/storm/mysql-reserved-words into lp:storm

Proposed by Jamu Kakar
Status: Merged
Approved by: James Henstridge
Approved revision: 330
Merged at revision: not available
Proposed branch: lp:~jkakar/storm/mysql-reserved-words
Merge into: lp:storm
Diff against target: None lines
To merge this branch: bzr merge lp:~jkakar/storm/mysql-reserved-words
Reviewer Review Type Date Requested Status
GabrielGrant (community) Approve
James Henstridge Approve
Review via email: mp+12173@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jamu Kakar (jkakar) wrote :

This branch registers all missing MySQL reserved words with the
compiler.

Revision history for this message
James Henstridge (jamesh) wrote :

Looks good to me. +1.

I wonder if there are any extra words we need to add for PostgreSQL and SQLite?

review: Approve
Revision history for this message
GabrielGrant (gabrielgrant) wrote :

simple patch, all tests pass. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storm/databases/mysql.py'
2--- storm/databases/mysql.py 2008-08-16 07:47:33 +0000
3+++ storm/databases/mysql.py 2009-09-21 17:03:08 +0000
4@@ -195,3 +195,31 @@
5 s = int(f)
6 return time(int(h), int(m), s, (f-s)*1000000)
7 return time(int(h), int(m), int(s), 0)
8+
9+
10+# --------------------------------------------------------------------
11+# Reserved words, MySQL specific
12+
13+# The list of reserved words here are MySQL specific. SQL92 reserved words
14+# are registered in storm.expr, near the "Reserved words, from SQL1992"
15+# comment. The reserved words here were taken from:
16+#
17+# http://dev.mysql.com/doc/refman/5.4/en/reserved-words.html
18+compile.add_reserved_words("""
19+ accessible analyze asensitive before bigint binary blob call change
20+ condition current_user database databases day_hour day_microsecond
21+ day_minute day_second delayed deterministic distinctrow div dual each
22+ elseif enclosed escaped exit explain float4 float8 force fulltext
23+ high_priority hour_microsecond hour_minute hour_second if ignore index
24+ infile inout int1 int2 int3 int4 int8 iterate keys kill leave limit linear
25+ lines load localtime localtimestamp lock long longblob longtext loop
26+ low_priority master_ssl_verify_server_cert mediumblob mediumint mediumtext
27+ middleint minute_microsecond minute_second mod modifies no_write_to_binlog
28+ optimize optionally out outfile purge range read_write reads regexp
29+ release rename repeat replace require return rlike schemas
30+ second_microsecond sensitive separator show spatial specific
31+ sql_big_result sql_calc_found_rows sql_small_result sqlexception
32+ sqlwarning ssl starting straight_join terminated tinyblob tinyint tinytext
33+ trigger undo unlock unsigned use utc_date utc_time utc_timestamp varbinary
34+ varcharacter while xor year_month zerofill
35+ """.split())
36
37=== modified file 'tests/databases/mysql.py'
38--- tests/databases/mysql.py 2008-08-16 07:47:33 +0000
39+++ tests/databases/mysql.py 2009-09-21 17:03:08 +0000
40@@ -106,9 +106,34 @@
41 result = self.connection.execute("SELECT MAX(id) FROM test")
42 self.assertEqual(result.get_one()[0], id_variable.get())
43
44+ def test_mysql_specific_reserved_words(self):
45+ reserved_words = """
46+ accessible analyze asensitive before bigint binary blob call
47+ change condition current_user database databases day_hour
48+ day_microsecond day_minute day_second delayed deterministic
49+ distinctrow div dual each elseif enclosed escaped exit explain
50+ float4 float8 force fulltext high_priority hour_microsecond
51+ hour_minute hour_second if ignore index infile inout int1 int2
52+ int3 int4 int8 iterate keys kill leave limit linear lines load
53+ localtime localtimestamp lock long longblob longtext loop
54+ low_priority master_ssl_verify_server_cert mediumblob mediumint
55+ mediumtext middleint minute_microsecond minute_second mod modifies
56+ no_write_to_binlog optimize optionally out outfile purge range
57+ read_write reads regexp release rename repeat replace require
58+ return rlike schemas second_microsecond sensitive separator show
59+ spatial specific sql_big_result sql_calc_found_rows
60+ sql_small_result sqlexception sqlwarning ssl starting
61+ straight_join terminated tinyblob tinyint tinytext trigger undo
62+ unlock unsigned use utc_date utc_time utc_timestamp varbinary
63+ varcharacter while xor year_month zerofill
64+ """.split()
65+ for word in reserved_words:
66+ self.assertTrue(self.connection.compile.is_reserved_word(word),
67+ "Word missing: %s" % (word,))
68+
69
70 class MySQLUnsupportedTest(UnsupportedDatabaseTest, TestHelper):
71-
72+
73 dbapi_module_names = ["MySQLdb"]
74 db_module_name = "mysql"
75

Subscribers

People subscribed via source and target branches

to status/vote changes: