         case .SubqueryExpressionType: fallthrough
         case .AggregateExpressionType: fallthrough
         case .AnyKeyExpressionType: fallthrough
-        case .BlockExpressionType:
-            return ("", nil)
+        case .BlockExpressionType: fallthrough
         default:
-            return ("", nil)
-        }
+            return ExpressionMeta(label: "", value: nil, column: nil)
+        }
+
     }
 
     public func compileComparisonPredicate(context: PredicateContext) -> (String, [AnyObject?]){
 
         let (left, right) = ExpressionContext.fromComparisionContext(context)
-        //  .Some, .Optional
-        let (a1, a2) = compile(left)
-        let (b1, b2) = compile(right)
-        let params = [a2, b2]
-
-        let sql = compile(context.comparisionPredicate.predicateOperatorType, left: a1, right: b1)
+
+        let metaLeft = compile(left)
+        let metaRight = compile(right)
+        let params = [metaLeft.column?.serialize(metaRight.value)]
+
+        let sql = compile(context.comparisionPredicate.predicateOperatorType, left: metaLeft.label, right: metaRight.label)
 
         return (sql, params)
     }

        case is NSComparisonPredicate:
            let (str, args) = compileComparisonPredicate(context)
            sql.append(str)
            params = params + args.filter{ $0 != nil }.map{$0!}

        case is NSCompoundPredicate:
            let (str, args) = compileCompoundPredicate(context)
            sql.append(str)
            params = params + args.filter{ $0 != nil }.map{$0!}
        default:()
        }

        return (sql.joinWithSeparator(" "), params)
    }

    public func compile(context: ExpressionContext) -> (AnyObject, AnyObject?){
        let expression = context.expression
        switch expression.expressionType{

        case .ConstantValueExpressionType:
            return ("?", expression.constantValue)
        case .KeyPathExpressionType:

            let parts = expression.keyPath.unicodeScalars.split{$0 == "."}.map(String.init).map{$0.lowercaseString}
            let column: String

            if parts.count == 1{
                column = context.table.columns[parts[0]]!.qualifiedLabel!
            } else if parts.count == 2{
                let key = parts[0] + "_id"
                column = context.table.columns[key]!.foreignKey!.relatedTable.columns[parts[1]]!.qualifiedLabel!
            } else { // fully qualified (count = 3) namespace | table | column
                let key = parts[1] + "_id"
                column = context.table.columns[key]!.foreignKey!.relatedColumn.qualifiedLabel!
            }

            return (column, nil)

        case .EvaluatedObjectExpressionType: fallthrough
        case .VariableExpressionType: fallthrough

    }
}

public struct ExpressionMeta{
    let label: String
    let value: AnyObject?
    let column: Column?
}

public struct SQLiteCompiler: Compiler{
    public let typeCompiler = SQLiteTypeCompiler()

