mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-10-31 17:50:11 +00:00 
			
		
		
		
	Fix creating DELETE sql statement with table alias
This commit is contained in:
		| @@ -25,7 +25,7 @@ object FromExprBuilder { | ||||
|  | ||||
|   def buildTable(table: TableDef): Fragment = | ||||
|     Fragment.const(table.tableName) ++ table.alias | ||||
|       .map(a => Fragment.const0(a)) | ||||
|       .map(a => Fragment.const(a)) | ||||
|       .getOrElse(Fragment.empty) | ||||
|  | ||||
|   def buildRelation(rel: FromExpr.Relation): Fragment = | ||||
|   | ||||
| @@ -17,6 +17,11 @@ class DSLTest extends FunSuite { | ||||
|   val course = CourseRecord.as("c") | ||||
|   val person = PersonRecord.as("p") | ||||
|  | ||||
|   test("delete") { | ||||
|     val frag = DML.deleteFragment(course, course.ownerId === 15L) | ||||
|     assertEquals(frag.internals.sql, "DELETE FROM course c WHERE c.owner_id = ? ") | ||||
|   } | ||||
|  | ||||
|   test("and") { | ||||
|     val c = course.lessons > 4 && person.id === 3 && person.name.like("%a%") | ||||
|     val expect = | ||||
|   | ||||
| @@ -32,8 +32,8 @@ class SelectBuilderTest extends FunSuite with TestLoggingConfig { | ||||
|     val q = Select(proj, table, cond) | ||||
|     val frag = SelectBuilder(q) | ||||
|     assertEquals( | ||||
|       frag.toString, | ||||
|       """Fragment("SELECT c.id, c.name, c.owner_id, c.lecturer_id, c.lessons FROM course c INNER JOIN person o ON c.owner_id = o.id LEFT JOIN person l ON c.lecturer_id = l.id WHERE (LOWER(c.name) LIKE ?  AND o.name = ? )")""" | ||||
|       frag.internals.sql, | ||||
|       """SELECT c.id, c.name, c.owner_id, c.lecturer_id, c.lessons FROM course c  INNER JOIN person o  ON c.owner_id = o.id LEFT JOIN person l  ON c.lecturer_id = l.id WHERE (LOWER(c.name) LIKE ?  AND o.name = ? )""" | ||||
|     ) | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user