Browse Source

allowed both search(expr,lock) and search(expr,opts) (fixed issue #494)

Nicolas Cannasse 14 years ago
parent
commit
9874e3ea5f
1 changed files with 9 additions and 4 deletions
  1. 9 4
      std/sys/db/SpodMacros.hx

+ 9 - 4
std/sys/db/SpodMacros.hx

@@ -976,10 +976,15 @@ class SpodMacros {
 	}
 
 	public static function macroSearch( em : Expr, econd : Expr, eopt : Expr, elock : Expr, ?single ) {
-		if( elock == null || Type.enumEq(elock.expr, EConst(CIdent("null"))) ) {
-			var tmp = eopt;
-			eopt = elock;
-			elock = tmp;
+		// allow both search(e,opts) and search(e,lock)
+		if( eopt != null && (elock == null || Type.enumEq(elock.expr, EConst(CIdent("null")))) ) {
+			switch( eopt.expr ) {
+			case EObjectDecl(_):
+			default:
+				var tmp = eopt;
+				eopt = elock;
+				elock = tmp;
+			}
 		}
 		var sql = buildSQL(em, econd, "SELECT * FROM", eopt);
 		var pos = Context.currentPos();