~ change quotes needed for non-ascii table/column names
authorEric Prud'hommeaux <eric@w3.org>
Wed, 16 Feb 2011 13:21:52 -0500
changeset 351 c74c83253026
parent 350 c69b9aac210c
child 352 f3cf25dbba52
~ change quotes needed for non-ascii table/column names
sql/src/main/scala/SQL.scala
sql/src/test/scala/SQLTest.scala
--- a/sql/src/main/scala/SQL.scala	Wed Feb 16 10:04:13 2011 -0500
+++ b/sql/src/main/scala/SQL.scala	Wed Feb 16 13:21:52 2011 -0500
@@ -347,12 +347,12 @@
 
   def attribute:Parser[RDB.AttrName] = (
       """[a-zA-Z_]\w*""".r ^^ { x => RDB.AttrName(x) }
-    | """'[^']+'""".r ^^ { x => RDB.AttrName(x.substring(1, x.size - 1)) }
+    | """`[^`]+`""".r ^^ { x => RDB.AttrName(x.substring(1, x.size - 1)) }
   )
 
   def attralias:Parser[AttrAlias] = (
       """[a-zA-Z_]\w*""".r ^^ { x => AttrAlias(Name(x)) }
-    | """'[^']+'""".r ^^ { x => AttrAlias(Name(x.substring(1, x.size - 1))) }
+    | """`[^`]+`""".r ^^ { x => AttrAlias(Name(x.substring(1, x.size - 1))) }
   )
 
   def relationORsubselect:Parser[RelationORSubselect] = (
@@ -362,12 +362,12 @@
 
   def relation:Parser[RDB.RelName] = (
       """[a-zA-Z_]\w*""".r ^^ { x => RDB.RelName(x) }
-    | """'[^']+'""".r ^^ { x => RDB.RelName(x.substring(1, x.size - 1)) }
+    | """`[^`]+`""".r ^^ { x => RDB.RelName(x.substring(1, x.size - 1)) }
   )
 
   def relvar:Parser[RelVar] = (
       """[a-zA-Z_]\w*""".r ^^ { x => RelVar(Name(x)) }
-    | """'[^']+'""".r ^^ { x => RelVar(Name(x)) }
+    | """`[^`]+`""".r ^^ { x => RelVar(Name(x)) }
   )
 
   def tablelist:Parser[(TableList, Set[Expression])] =
--- a/sql/src/test/scala/SQLTest.scala	Wed Feb 16 10:04:13 2011 -0500
+++ b/sql/src/test/scala/SQLTest.scala	Wed Feb 16 13:21:52 2011 -0500
@@ -1032,8 +1032,8 @@
   test("parse single-quoted CJK") {
     val p = SqlParser()
     val s = """
-CREATE TABLE '植物' ('名' varchar(50));
-INSERT INTO '植物' ('名') VALUES ('シソ');
+CREATE TABLE `植物` (`名` varchar(50));
+INSERT INTO `植物` (`名`) VALUES ('シソ');
 """
     val addrs = RDB.Relation(
       "植物",