diff --git a/EvaluableExpression_sql.go b/EvaluableExpression_sql.go index 673f3dc..b6d632e 100644 --- a/EvaluableExpression_sql.go +++ b/EvaluableExpression_sql.go @@ -108,32 +108,9 @@ func (this EvaluableExpression) findNextSQLString(stream *tokenStream, transacti ret = fmt.Sprintf("COALESCE(%v, %v)", left, right) case TERNARY_TRUE: - - left := transactions.rollback() - right, err := this.findNextSQLString(stream, transactions) - if err != nil { - return "", err - } - - // ternaries are weird, in that we handle the else case slightly differently than the half case. - - if !stream.hasNext() { - break - } - - nextToken := stream.next() - if nextToken.Kind == TERNARY { - - last, err := this.findNextSQLString(stream, transactions) - if err != nil { - return "", err - } - - ret = fmt.Sprintf("IF(%s, %s, %s)", left, right, last) - break - } - - ret = fmt.Sprintf("IF(%s, %s)", left, right) + fallthrough + case TERNARY_FALSE: + return "", errors.New("Ternary operators are unsupported in SQL output") } case PREFIX: switch PREFIX_SYMBOLS[token.Value.(string)] { diff --git a/sql_test.go b/sql_test.go index 607d21c..b0f4c9a 100644 --- a/sql_test.go +++ b/sql_test.go @@ -154,7 +154,7 @@ func TestSQLSerialization(test *testing.T) { Name: "Membership operator", Input: "foo IN (1, 2, 3)", - Expected: "FIND_IN_SET([foo], '1,2,3') > 0 ", + Expected: "[foo] in ( 1 , 2 , 3 )", }, QueryTest{ @@ -162,6 +162,8 @@ func TestSQLSerialization(test *testing.T) { Input: "foo ?? bar", Expected: "COALESCE([foo], [bar])", }, + /* + // Ternaries don't work yet, because the outputter is not yet sophisticated enough to produce them. QueryTest{ Name: "Full ternary", @@ -185,7 +187,7 @@ func TestSQLSerialization(test *testing.T) { Name: "Half ternary with implicit bool", Input: "[foo] ? 1", Expected: "IF([foo] = 0, 1)", - }, + },*/ QueryTest{ Name: "Regex equals",