@ -19,9 +19,10 @@
( let ( ( ssql-op ( first op ) )
( let ( ( ssql-op ( first op ) )
( type ( second op ) ) )
( type ( second op ) ) )
( let-optionals ( cddr op )
( let-optionals ( cddr op )
( ( sql-op ( string-upcase ( ->string ( strip-syntax ssql-op ) ) ) ) )
( ( sql-op ( string-upcase ( ->string ( strip-syntax ssql-op ) ) ) )
( separator #f ) )
` ( ( , ( strip-syntax ssql-op ) operands )
` ( ( , ( strip-syntax ssql-op ) operands )
( self 'operator->sql ',type , sql-op operands ) ) ) ) )
( self 'operator->sql ',type , sql-op , separator operands ) ) ) ) )
( cddr x ) ) ) ) ) ) ) )
( cddr x ) ) ) ) ) ) ) )
( define *ansi-translator*
( define *ansi-translator*
@ -69,7 +70,7 @@
( string-upcase ( symbol->string type ) )
( string-upcase ( symbol->string type ) )
( string-join ( map ( lambda ( x ) ( self 'ssql->sql x ) ) rest ) ) ) ) ) )
( string-join ( map ( lambda ( x ) ( self 'ssql->sql x ) ) rest ) ) ) ) ) )
( ( operator->sql type operator operands)
( ( operator->sql type operator separator operands)
( case type
( case type
( ( infix )
( ( infix )
( sprintf "(~A)" ( string-intersperse
( sprintf "(~A)" ( string-intersperse
@ -84,20 +85,20 @@
( map ( lambda ( operand )
( map ( lambda ( operand )
( self 'ssql->sql operand ) )
( self 'ssql->sql operand ) )
operands )
operands )
", " ) ) )
( or separator ", " ) ) ) )
( ( suffix prefix )
( ( suffix prefix )
( let ( ( operator ( if ( eq? type 'prefix )
( let ( ( operator ( if ( eq? type 'prefix )
( string-append operator " " )
( string-append operator " " )
( string-append " " operator ) ) ) )
( string-append " " operator ) ) ) )
( sprintf "(~A)"
( string-join
( string-join
( list
( list
( string-intersperse
( string-intersperse
( map ( lambda ( operand )
( map ( lambda ( operand )
( self 'ssql->sql operand ) )
( self 'ssql->sql operand ) )
operands ) ) )
operands )
( or separator " " ) ) )
operator
operator
type ) ) ) )
type ) ) )
( else ( error "unknown operator syntax type" type ) ) ) )
( else ( error "unknown operator syntax type" type ) ) ) )
( ( ssql->sql ssql )
( ( ssql->sql ssql )
@ -108,8 +109,9 @@
( define-operators *ansi-translator*
( define-operators *ansi-translator*
( select prefix )
( select prefix )
( from prefix )
( from prefix "FROM" ", " )
( where prefix )
( where prefix )
( order prefix "ORDER BY" ", " )
( having prefix )
( having prefix )
( union infix )
( union infix )
( as infix )
( as infix )