Merge lp:~mmcm/akiban-sql-parser/more-node-to-string into lp:~akiban-technologies/akiban-sql-parser/trunk
- more-node-to-string
- Merge into trunk
Proposed by
Mike McMahon
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Nathan Williams | ||||
Approved revision: | 305 | ||||
Merged at revision: | 302 | ||||
Proposed branch: | lp:~mmcm/akiban-sql-parser/more-node-to-string | ||||
Merge into: | lp:~akiban-technologies/akiban-sql-parser/trunk | ||||
Diff against target: |
367 lines (+209/-4) 7 files modified
src/main/java/com/akiban/sql/parser/LeftRightFuncOperatorNode.java (+2/-2) src/main/java/com/akiban/sql/parser/TrimOperatorNode.java (+1/-1) src/main/java/com/akiban/sql/parser/UnaryArithmeticOperatorNode.java (+1/-1) src/main/java/com/akiban/sql/unparser/NodeToString.java (+188/-0) src/test/java/com/akiban/sql/unparser/NodeToStringTest.java (+3/-0) src/test/resources/com/akiban/sql/unparser/select-15.expected (+1/-0) src/test/resources/com/akiban/sql/unparser/select-15.sql (+13/-0) |
||||
To merge this branch: | bzr merge lp:~mmcm/akiban-sql-parser/more-node-to-string | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Thomas Jones-Low | Needs Fixing | ||
Nathan Williams | Approve | ||
Review via email: mp+177704@code.launchpad.net |
Commit message
Description of the change
Add unparser support for missing Value-like nodes.
See switch additions for which node types these are and new test for how those manifest in the parser.
To post a comment you must log in.
Revision history for this message
Thomas Jones-Low (tjoneslo) wrote : | # |
There were 2 failures during build/test:
* job sql-parser-build failed at build number 296: http://
* view must-pass failed: sql-parser-build is red
review:
Needs Fixing
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/main/java/com/akiban/sql/parser/LeftRightFuncOperatorNode.java' | |||
2 | --- src/main/java/com/akiban/sql/parser/LeftRightFuncOperatorNode.java 2013-05-08 22:13:20 +0000 | |||
3 | +++ src/main/java/com/akiban/sql/parser/LeftRightFuncOperatorNode.java 2013-07-30 22:21:25 +0000 | |||
4 | @@ -36,11 +36,11 @@ | |||
5 | 36 | switch(nodeType) | 36 | switch(nodeType) |
6 | 37 | { | 37 | { |
7 | 38 | case NodeTypes.LEFT_FN_NODE: | 38 | case NodeTypes.LEFT_FN_NODE: |
9 | 39 | op = "getLeft"; | 39 | op = "LEFT"; |
10 | 40 | method = "getLeft"; | 40 | method = "getLeft"; |
11 | 41 | break; | 41 | break; |
12 | 42 | case NodeTypes.RIGHT_FN_NODE: | 42 | case NodeTypes.RIGHT_FN_NODE: |
14 | 43 | op = "getRight"; | 43 | op = "RIGHT"; |
15 | 44 | method = "getRight"; | 44 | method = "getRight"; |
16 | 45 | break; | 45 | break; |
17 | 46 | default: | 46 | default: |
18 | 47 | 47 | ||
19 | === modified file 'src/main/java/com/akiban/sql/parser/TrimOperatorNode.java' | |||
20 | --- src/main/java/com/akiban/sql/parser/TrimOperatorNode.java 2013-05-08 22:13:20 +0000 | |||
21 | +++ src/main/java/com/akiban/sql/parser/TrimOperatorNode.java 2013-07-30 22:21:25 +0000 | |||
22 | @@ -31,7 +31,7 @@ | |||
23 | 31 | case TRIM: | 31 | case TRIM: |
24 | 32 | case RTRIM: super.init(trimSource, | 32 | case RTRIM: super.init(trimSource, |
25 | 33 | trimChar, | 33 | trimChar, |
27 | 34 | "TRIM", | 34 | optype.name(), |
28 | 35 | optype.name().toLowerCase(), | 35 | optype.name().toLowerCase(), |
29 | 36 | ValueClassName.StringDataValue, | 36 | ValueClassName.StringDataValue, |
30 | 37 | ValueClassName.StringDataValue); | 37 | ValueClassName.StringDataValue); |
31 | 38 | 38 | ||
32 | === modified file 'src/main/java/com/akiban/sql/parser/UnaryArithmeticOperatorNode.java' | |||
33 | --- src/main/java/com/akiban/sql/parser/UnaryArithmeticOperatorNode.java 2013-05-08 22:13:20 +0000 | |||
34 | +++ src/main/java/com/akiban/sql/parser/UnaryArithmeticOperatorNode.java 2013-07-30 22:21:25 +0000 | |||
35 | @@ -52,7 +52,7 @@ | |||
36 | 52 | PLUS("+", "plus"), | 52 | PLUS("+", "plus"), |
37 | 53 | MINUS("-", "minus"), | 53 | MINUS("-", "minus"), |
38 | 54 | SQRT("SQRT", "sqrt"), | 54 | SQRT("SQRT", "sqrt"), |
40 | 55 | ABSOLUTE("ABS/ABSVAL", "absolute"); | 55 | ABSOLUTE("ABS", "absolute"); |
41 | 56 | 56 | ||
42 | 57 | String operator, methodName; | 57 | String operator, methodName; |
43 | 58 | OperatorType(String operator, String methodName) { | 58 | OperatorType(String operator, String methodName) { |
44 | 59 | 59 | ||
45 | === modified file 'src/main/java/com/akiban/sql/unparser/NodeToString.java' | |||
46 | --- src/main/java/com/akiban/sql/unparser/NodeToString.java 2013-05-08 22:13:20 +0000 | |||
47 | +++ src/main/java/com/akiban/sql/unparser/NodeToString.java 2013-07-30 22:21:25 +0000 | |||
48 | @@ -131,7 +131,10 @@ | |||
49 | 131 | case NodeTypes.BINARY_DIVIDE_OPERATOR_NODE: | 131 | case NodeTypes.BINARY_DIVIDE_OPERATOR_NODE: |
50 | 132 | case NodeTypes.BINARY_DIV_OPERATOR_NODE: | 132 | case NodeTypes.BINARY_DIV_OPERATOR_NODE: |
51 | 133 | case NodeTypes.BINARY_MINUS_OPERATOR_NODE: | 133 | case NodeTypes.BINARY_MINUS_OPERATOR_NODE: |
52 | 134 | case NodeTypes.MOD_OPERATOR_NODE: | ||
53 | 134 | return binaryArithmeticOperatorNode((BinaryArithmeticOperatorNode)node); | 135 | return binaryArithmeticOperatorNode((BinaryArithmeticOperatorNode)node); |
54 | 136 | case NodeTypes.BINARY_BIT_OPERATOR_NODE: | ||
55 | 137 | return binaryBitOperatorNode((BinaryBitOperatorNode)node); | ||
56 | 135 | case NodeTypes.CONCATENATION_OPERATOR_NODE: | 138 | case NodeTypes.CONCATENATION_OPERATOR_NODE: |
57 | 136 | return concatenationOperatorNode((ConcatenationOperatorNode)node); | 139 | return concatenationOperatorNode((ConcatenationOperatorNode)node); |
58 | 137 | case NodeTypes.NOT_NODE: | 140 | case NodeTypes.NOT_NODE: |
59 | @@ -141,10 +144,39 @@ | |||
60 | 141 | return isNullNode((IsNullNode)node); | 144 | return isNullNode((IsNullNode)node); |
61 | 142 | case NodeTypes.IS_NODE: | 145 | case NodeTypes.IS_NODE: |
62 | 143 | return isNode((IsNode)node); | 146 | return isNode((IsNode)node); |
63 | 147 | case NodeTypes.ABSOLUTE_OPERATOR_NODE: | ||
64 | 148 | case NodeTypes.SQRT_OPERATOR_NODE: | ||
65 | 149 | return unaryArithmeticOperatorNode((UnaryArithmeticOperatorNode)node); | ||
66 | 150 | case NodeTypes.UNARY_PLUS_OPERATOR_NODE: | ||
67 | 151 | case NodeTypes.UNARY_MINUS_OPERATOR_NODE: | ||
68 | 152 | return unaryPrefixOperatorNode((UnaryArithmeticOperatorNode)node); | ||
69 | 153 | case NodeTypes.UNARY_BITNOT_OPERATOR_NODE: | ||
70 | 154 | return unaryBitOperatorNode((UnaryBitOperatorNode)node); | ||
71 | 144 | case NodeTypes.UNARY_DATE_TIMESTAMP_OPERATOR_NODE: | 155 | case NodeTypes.UNARY_DATE_TIMESTAMP_OPERATOR_NODE: |
72 | 145 | return unaryDateTimestampOperatorNode((UnaryDateTimestampOperatorNode)node); | 156 | return unaryDateTimestampOperatorNode((UnaryDateTimestampOperatorNode)node); |
73 | 157 | case NodeTypes.TIMESTAMP_OPERATOR_NODE: | ||
74 | 158 | return timestampOperatorNode((TimestampOperatorNode)node); | ||
75 | 159 | case NodeTypes.EXTRACT_OPERATOR_NODE: | ||
76 | 160 | return extractOperatorNode((ExtractOperatorNode)node); | ||
77 | 161 | case NodeTypes.CHAR_LENGTH_OPERATOR_NODE: | ||
78 | 162 | return lengthOperatorNode((LengthOperatorNode)node); | ||
79 | 163 | case NodeTypes.OCTET_LENGTH_OPERATOR_NODE: | ||
80 | 164 | return octetLengthOperatorNode((OctetLengthOperatorNode)node); | ||
81 | 165 | case NodeTypes.RIGHT_FN_NODE: | ||
82 | 166 | case NodeTypes.LEFT_FN_NODE: | ||
83 | 167 | return leftRightFuncOperatorNode((LeftRightFuncOperatorNode)node); | ||
84 | 168 | case NodeTypes.SIMPLE_STRING_OPERATOR_NODE: | ||
85 | 169 | return simpleStringOperatorNode((SimpleStringOperatorNode)node); | ||
86 | 146 | case NodeTypes.LIKE_OPERATOR_NODE: | 170 | case NodeTypes.LIKE_OPERATOR_NODE: |
87 | 147 | return likeEscapeOperatorNode((LikeEscapeOperatorNode)node); | 171 | return likeEscapeOperatorNode((LikeEscapeOperatorNode)node); |
88 | 172 | case NodeTypes.LOCATE_FUNCTION_NODE: | ||
89 | 173 | case NodeTypes.SUBSTRING_OPERATOR_NODE: | ||
90 | 174 | return ternaryOperatorNode((TernaryOperatorNode)node); | ||
91 | 175 | case NodeTypes.TIMESTAMP_ADD_FN_NODE: | ||
92 | 176 | case NodeTypes.TIMESTAMP_DIFF_FN_NODE: | ||
93 | 177 | return timestampFunctionNode((TernaryOperatorNode)node); | ||
94 | 178 | case NodeTypes.TRIM_OPERATOR_NODE: | ||
95 | 179 | return trimOperatorNode((TrimOperatorNode)node); | ||
96 | 148 | case NodeTypes.IN_LIST_OPERATOR_NODE: | 180 | case NodeTypes.IN_LIST_OPERATOR_NODE: |
97 | 149 | return inListOperatorNode((InListOperatorNode)node); | 181 | return inListOperatorNode((InListOperatorNode)node); |
98 | 150 | case NodeTypes.ROW_CTOR_NODE: | 182 | case NodeTypes.ROW_CTOR_NODE: |
99 | @@ -180,6 +212,8 @@ | |||
100 | 180 | return constantNode((ConstantNode)node); | 212 | return constantNode((ConstantNode)node); |
101 | 181 | case NodeTypes.PARAMETER_NODE: | 213 | case NodeTypes.PARAMETER_NODE: |
102 | 182 | return parameterNode((ParameterNode)node); | 214 | return parameterNode((ParameterNode)node); |
103 | 215 | case NodeTypes.DEFAULT_NODE: | ||
104 | 216 | return "DEFAULT"; | ||
105 | 183 | case NodeTypes.USER_NODE: | 217 | case NodeTypes.USER_NODE: |
106 | 184 | return "USER"; | 218 | return "USER"; |
107 | 185 | case NodeTypes.CURRENT_USER_NODE: | 219 | case NodeTypes.CURRENT_USER_NODE: |
108 | @@ -200,6 +234,12 @@ | |||
109 | 200 | return currentDatetimeOperatorNode((CurrentDatetimeOperatorNode)node); | 234 | return currentDatetimeOperatorNode((CurrentDatetimeOperatorNode)node); |
110 | 201 | case NodeTypes.CAST_NODE: | 235 | case NodeTypes.CAST_NODE: |
111 | 202 | return castNode((CastNode)node); | 236 | return castNode((CastNode)node); |
112 | 237 | case NodeTypes.EXPLICIT_COLLATE_NODE: | ||
113 | 238 | return explicitCollateNode((ExplicitCollateNode)node); | ||
114 | 239 | case NodeTypes.NEXT_SEQUENCE_NODE: | ||
115 | 240 | return nextSequenceNode((NextSequenceNode)node); | ||
116 | 241 | case NodeTypes.CURRENT_SEQUENCE_NODE: | ||
117 | 242 | return currentSequenceNode((CurrentSequenceNode)node); | ||
118 | 203 | case NodeTypes.JAVA_TO_SQL_VALUE_NODE: | 243 | case NodeTypes.JAVA_TO_SQL_VALUE_NODE: |
119 | 204 | return javaToSQLValueNode((JavaToSQLValueNode)node); | 244 | return javaToSQLValueNode((JavaToSQLValueNode)node); |
120 | 205 | case NodeTypes.SQL_TO_JAVA_VALUE_NODE: | 245 | case NodeTypes.SQL_TO_JAVA_VALUE_NODE: |
121 | @@ -747,11 +787,26 @@ | |||
122 | 747 | return infixBinary(node); | 787 | return infixBinary(node); |
123 | 748 | } | 788 | } |
124 | 749 | 789 | ||
125 | 790 | protected String binaryBitOperatorNode(BinaryBitOperatorNode node) | ||
126 | 791 | throws StandardException { | ||
127 | 792 | return infixBinary(node); | ||
128 | 793 | } | ||
129 | 794 | |||
130 | 750 | protected String concatenationOperatorNode(ConcatenationOperatorNode node) | 795 | protected String concatenationOperatorNode(ConcatenationOperatorNode node) |
131 | 751 | throws StandardException { | 796 | throws StandardException { |
132 | 752 | return infixBinary(node); | 797 | return infixBinary(node); |
133 | 753 | } | 798 | } |
134 | 754 | 799 | ||
135 | 800 | protected String leftRightFuncOperatorNode(LeftRightFuncOperatorNode node) | ||
136 | 801 | throws StandardException { | ||
137 | 802 | return functionBinary(node); | ||
138 | 803 | } | ||
139 | 804 | |||
140 | 805 | protected String simpleStringOperatorNode(SimpleStringOperatorNode node) | ||
141 | 806 | throws StandardException { | ||
142 | 807 | return functionUnary(node); | ||
143 | 808 | } | ||
144 | 809 | |||
145 | 755 | protected String notNode(NotNode node) throws StandardException { | 810 | protected String notNode(NotNode node) throws StandardException { |
146 | 756 | return prefixUnary(node); | 811 | return prefixUnary(node); |
147 | 757 | } | 812 | } |
148 | @@ -760,11 +815,47 @@ | |||
149 | 760 | return suffixUnary(node); | 815 | return suffixUnary(node); |
150 | 761 | } | 816 | } |
151 | 762 | 817 | ||
152 | 818 | protected String unaryArithmeticOperatorNode(UnaryArithmeticOperatorNode node) | ||
153 | 819 | throws StandardException { | ||
154 | 820 | return functionUnary(node); | ||
155 | 821 | } | ||
156 | 822 | |||
157 | 823 | protected String unaryPrefixOperatorNode(UnaryArithmeticOperatorNode node) | ||
158 | 824 | throws StandardException { | ||
159 | 825 | return prefixUnary(node); | ||
160 | 826 | } | ||
161 | 827 | |||
162 | 828 | protected String unaryBitOperatorNode(UnaryBitOperatorNode node) | ||
163 | 829 | throws StandardException { | ||
164 | 830 | return prefixUnary(node); | ||
165 | 831 | } | ||
166 | 832 | |||
167 | 833 | protected String extractOperatorNode(ExtractOperatorNode node) | ||
168 | 834 | throws StandardException { | ||
169 | 835 | return node.getOperator().substring("EXTRACT ".length()).toUpperCase() + "(" + | ||
170 | 836 | toString(node.getOperand()) + ")"; | ||
171 | 837 | } | ||
172 | 838 | |||
173 | 763 | protected String unaryDateTimestampOperatorNode(UnaryDateTimestampOperatorNode node) | 839 | protected String unaryDateTimestampOperatorNode(UnaryDateTimestampOperatorNode node) |
174 | 764 | throws StandardException { | 840 | throws StandardException { |
175 | 765 | return functionUnary(node); | 841 | return functionUnary(node); |
176 | 766 | } | 842 | } |
177 | 767 | 843 | ||
178 | 844 | protected String timestampOperatorNode(TimestampOperatorNode node) | ||
179 | 845 | throws StandardException { | ||
180 | 846 | return functionBinary(node); | ||
181 | 847 | } | ||
182 | 848 | |||
183 | 849 | protected String lengthOperatorNode(LengthOperatorNode node) | ||
184 | 850 | throws StandardException { | ||
185 | 851 | return functionUnary(node); | ||
186 | 852 | } | ||
187 | 853 | |||
188 | 854 | protected String octetLengthOperatorNode(OctetLengthOperatorNode node) | ||
189 | 855 | throws StandardException { | ||
190 | 856 | return functionUnary(node); | ||
191 | 857 | } | ||
192 | 858 | |||
193 | 768 | protected String isNode(IsNode node) throws StandardException { | 859 | protected String isNode(IsNode node) throws StandardException { |
194 | 769 | StringBuilder str = new StringBuilder(maybeParens(node.getLeftOperand())); | 860 | StringBuilder str = new StringBuilder(maybeParens(node.getLeftOperand())); |
195 | 770 | str.append(" IS "); | 861 | str.append(" IS "); |
196 | @@ -800,6 +891,81 @@ | |||
197 | 800 | return like; | 891 | return like; |
198 | 801 | } | 892 | } |
199 | 802 | 893 | ||
200 | 894 | protected String ternaryOperatorNode(TernaryOperatorNode node) | ||
201 | 895 | throws StandardException { | ||
202 | 896 | StringBuilder str = new StringBuilder(node.getOperator().toUpperCase()); | ||
203 | 897 | str.append("("); | ||
204 | 898 | str.append(toString(node.getReceiver())); | ||
205 | 899 | str.append(", "); | ||
206 | 900 | str.append(toString(node.getLeftOperand())); | ||
207 | 901 | if (node.getRightOperand() != null) { | ||
208 | 902 | str.append(", "); | ||
209 | 903 | str.append(toString(node.getRightOperand())); | ||
210 | 904 | } | ||
211 | 905 | return str.toString(); | ||
212 | 906 | } | ||
213 | 907 | |||
214 | 908 | protected String timestampFunctionNode(TernaryOperatorNode node) | ||
215 | 909 | throws StandardException { | ||
216 | 910 | String interval = toString(node.getReceiver()); | ||
217 | 911 | switch ((Integer)((ConstantNode)node.getReceiver()).getValue()) { | ||
218 | 912 | case TernaryOperatorNode.YEAR_INTERVAL: | ||
219 | 913 | interval = "YEAR"; | ||
220 | 914 | break; | ||
221 | 915 | case TernaryOperatorNode.QUARTER_INTERVAL: | ||
222 | 916 | interval = "QUARTER"; | ||
223 | 917 | break; | ||
224 | 918 | case TernaryOperatorNode.MONTH_INTERVAL: | ||
225 | 919 | interval = "MONTH"; | ||
226 | 920 | break; | ||
227 | 921 | case TernaryOperatorNode.WEEK_INTERVAL: | ||
228 | 922 | interval = "WEEK"; | ||
229 | 923 | break; | ||
230 | 924 | case TernaryOperatorNode.DAY_INTERVAL: | ||
231 | 925 | interval = "DAY"; | ||
232 | 926 | break; | ||
233 | 927 | case TernaryOperatorNode.HOUR_INTERVAL: | ||
234 | 928 | interval = "HOUR"; | ||
235 | 929 | break; | ||
236 | 930 | case TernaryOperatorNode.MINUTE_INTERVAL: | ||
237 | 931 | interval = "MINUTE"; | ||
238 | 932 | break; | ||
239 | 933 | case TernaryOperatorNode.SECOND_INTERVAL: | ||
240 | 934 | interval = "SECOND"; | ||
241 | 935 | break; | ||
242 | 936 | case TernaryOperatorNode.FRAC_SECOND_INTERVAL: | ||
243 | 937 | interval = "MICROSECOND>"; | ||
244 | 938 | break; | ||
245 | 939 | } | ||
246 | 940 | return node.getOperator().toUpperCase() + "(" + | ||
247 | 941 | interval + ", " + | ||
248 | 942 | toString(node.getLeftOperand()) + ", " + | ||
249 | 943 | toString(node.getRightOperand()) + ")"; | ||
250 | 944 | } | ||
251 | 945 | |||
252 | 946 | protected String trimOperatorNode(TrimOperatorNode node) | ||
253 | 947 | throws StandardException { | ||
254 | 948 | if ((node.getRightOperand() instanceof ConstantNode) && | ||
255 | 949 | " ".equals(((ConstantNode)node.getRightOperand()).getValue())) { | ||
256 | 950 | return node.getOperator().toUpperCase() + "(" + | ||
257 | 951 | toString(node.getLeftOperand()) + ")"; | ||
258 | 952 | } | ||
259 | 953 | else { | ||
260 | 954 | StringBuilder str = new StringBuilder("TRIM("); | ||
261 | 955 | if ("LTRIM".equals(node.getOperator())) | ||
262 | 956 | str.append("LEADING"); | ||
263 | 957 | else if ("RTRIM".equals(node.getOperator())) | ||
264 | 958 | str.append("TRAILING"); | ||
265 | 959 | else | ||
266 | 960 | str.append("BOTH"); | ||
267 | 961 | str.append(" "); | ||
268 | 962 | str.append(toString(node.getRightOperand())); | ||
269 | 963 | str.append(" FROM "); | ||
270 | 964 | str.append(toString(node.getLeftOperand())); | ||
271 | 965 | return str.toString(); | ||
272 | 966 | } | ||
273 | 967 | } | ||
274 | 968 | |||
275 | 803 | protected String inListOperatorNode(InListOperatorNode node) throws StandardException { | 969 | protected String inListOperatorNode(InListOperatorNode node) throws StandardException { |
276 | 804 | return maybeParens(node.getLeftOperand()) + | 970 | return maybeParens(node.getLeftOperand()) + |
277 | 805 | " " + (node.isNegated() ? "NOT IN" : "IN") + | 971 | " " + (node.isNegated() ? "NOT IN" : "IN") + |
278 | @@ -880,6 +1046,12 @@ | |||
279 | 880 | maybeParens(node.getRightOperand()); | 1046 | maybeParens(node.getRightOperand()); |
280 | 881 | } | 1047 | } |
281 | 882 | 1048 | ||
282 | 1049 | protected String functionBinary(BinaryOperatorNode node) throws StandardException { | ||
283 | 1050 | return node.getOperator().toUpperCase() + "(" + | ||
284 | 1051 | toString(node.getLeftOperand()) + ", " + | ||
285 | 1052 | toString(node.getRightOperand()) + ")"; | ||
286 | 1053 | } | ||
287 | 1054 | |||
288 | 883 | protected String functionCall(String functionName, ValueNodeList args) | 1055 | protected String functionCall(String functionName, ValueNodeList args) |
289 | 884 | throws StandardException { | 1056 | throws StandardException { |
290 | 885 | return functionName + "(" + nodeList(args, true) + ")"; | 1057 | return functionName + "(" + nodeList(args, true) + ")"; |
291 | @@ -946,6 +1118,22 @@ | |||
292 | 946 | " AS " + node.getType().toString() + ")"; | 1118 | " AS " + node.getType().toString() + ")"; |
293 | 947 | } | 1119 | } |
294 | 948 | 1120 | ||
295 | 1121 | protected String explicitCollateNode(ExplicitCollateNode node) | ||
296 | 1122 | throws StandardException { | ||
297 | 1123 | return maybeParens(node.getOperand()) + | ||
298 | 1124 | " COLLATE " + node.getCollation(); | ||
299 | 1125 | } | ||
300 | 1126 | |||
301 | 1127 | protected String nextSequenceNode(NextSequenceNode node) | ||
302 | 1128 | throws StandardException { | ||
303 | 1129 | return "NEXT VALUE FOR " + toString(node.getSequenceName ()); | ||
304 | 1130 | } | ||
305 | 1131 | |||
306 | 1132 | protected String currentSequenceNode(CurrentSequenceNode node) | ||
307 | 1133 | throws StandardException { | ||
308 | 1134 | return "CURRENT VALUE FOR " + toString(node.getSequenceName ()); | ||
309 | 1135 | } | ||
310 | 1136 | |||
311 | 949 | protected String javaToSQLValueNode(JavaToSQLValueNode node) | 1137 | protected String javaToSQLValueNode(JavaToSQLValueNode node) |
312 | 950 | throws StandardException { | 1138 | throws StandardException { |
313 | 951 | return toString(node.getJavaValueNode()); | 1139 | return toString(node.getJavaValueNode()); |
314 | 952 | 1140 | ||
315 | === modified file 'src/test/java/com/akiban/sql/unparser/NodeToStringTest.java' | |||
316 | --- src/test/java/com/akiban/sql/unparser/NodeToStringTest.java 2013-05-08 22:13:20 +0000 | |||
317 | +++ src/test/java/com/akiban/sql/unparser/NodeToStringTest.java 2013-07-30 22:21:25 +0000 | |||
318 | @@ -19,6 +19,7 @@ | |||
319 | 19 | import com.akiban.sql.TestBase; | 19 | import com.akiban.sql.TestBase; |
320 | 20 | 20 | ||
321 | 21 | import com.akiban.sql.parser.SQLParser; | 21 | import com.akiban.sql.parser.SQLParser; |
322 | 22 | import com.akiban.sql.parser.SQLParserFeature; | ||
323 | 22 | import com.akiban.sql.parser.StatementNode; | 23 | import com.akiban.sql.parser.StatementNode; |
324 | 23 | 24 | ||
325 | 24 | import org.junit.Before; | 25 | import org.junit.Before; |
326 | @@ -30,6 +31,7 @@ | |||
327 | 30 | 31 | ||
328 | 31 | import java.io.File; | 32 | import java.io.File; |
329 | 32 | import java.util.Collection; | 33 | import java.util.Collection; |
330 | 34 | import java.util.EnumSet; | ||
331 | 33 | 35 | ||
332 | 34 | @RunWith(Parameterized.class) | 36 | @RunWith(Parameterized.class) |
333 | 35 | public class NodeToStringTest extends TestBase implements TestBase.GenerateAndCheckResult | 37 | public class NodeToStringTest extends TestBase implements TestBase.GenerateAndCheckResult |
334 | @@ -45,6 +47,7 @@ | |||
335 | 45 | public void before() throws Exception { | 47 | public void before() throws Exception { |
336 | 46 | parser = new SQLParser(); | 48 | parser = new SQLParser(); |
337 | 47 | unparser = new NodeToString(); | 49 | unparser = new NodeToString(); |
338 | 50 | parser.getFeatures().addAll(EnumSet.of(SQLParserFeature.INFIX_BIT_OPERATORS)); | ||
339 | 48 | } | 51 | } |
340 | 49 | 52 | ||
341 | 50 | @Parameters | 53 | @Parameters |
342 | 51 | 54 | ||
343 | === added file 'src/test/resources/com/akiban/sql/unparser/select-15.expected' | |||
344 | --- src/test/resources/com/akiban/sql/unparser/select-15.expected 1970-01-01 00:00:00 +0000 | |||
345 | +++ src/test/resources/com/akiban/sql/unparser/select-15.expected 2013-07-30 22:21:25 +0000 | |||
346 | @@ -0,0 +1,1 @@ | |||
347 | 1 | SELECT (ABS(- n)), (~ n), (n MOD 3), SQRT(n), CHAR_LENGTH(s), LENGTH(s), (LEFT(s, 3)), (RIGHT(s, 4)), UPPER(s), LOWER(s), (LOCATE(s, 'abc', 1), (LOCATE(s, 'xyz', 10), (SUBSTRING(s, 10), (SUBSTRING(s, 10, 3), LTRIM(s), (TRIM(TRAILING '!' FROM s), ((s || s) COLLATE en_us_ci), MONTH(d), (TIMESTAMP(d, '13:01:01')), (TIMESTAMPDIFF(DAY, d, CURRENT_TIMESTAMP)), (NEXT VALUE FOR seq), (CURRENT VALUE FOR seq) FROM t | ||
348 | 0 | \ No newline at end of file | 2 | \ No newline at end of file |
349 | 1 | 3 | ||
350 | === added file 'src/test/resources/com/akiban/sql/unparser/select-15.sql' | |||
351 | --- src/test/resources/com/akiban/sql/unparser/select-15.sql 1970-01-01 00:00:00 +0000 | |||
352 | +++ src/test/resources/com/akiban/sql/unparser/select-15.sql 2013-07-30 22:21:25 +0000 | |||
353 | @@ -0,0 +1,13 @@ | |||
354 | 1 | SELECT abs(- n), ~n, | ||
355 | 2 | mod(n, 3), sqrt(n), | ||
356 | 3 | char_length(s), octet_length(s), | ||
357 | 4 | left(s, 3), right(s, 4), | ||
358 | 5 | upper(s), lower(s), | ||
359 | 6 | locate(s, 'abc'), locate(s, 'xyz', 10), | ||
360 | 7 | substring(s, 10), substring(s, 10, 3), | ||
361 | 8 | ltrim(s), trim(trailing '!' from s), | ||
362 | 9 | s||s collate en_us_ci, | ||
363 | 10 | month(d), timestamp(d, '13:01:01'), timestampdiff(day, d, current_timestamp), | ||
364 | 11 | next value for seq, current value for seq | ||
365 | 12 | FROM t | ||
366 | 13 | |||
367 | 0 | \ No newline at end of file | 14 | \ No newline at end of file |
Looks good.