mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#583 - MSSQL Server - Delete query syntax error, mssql does not like the table alias in the delete statement
This commit is contained in:
@@ -41,7 +41,7 @@ public class TestDeleteByQuery extends BaseTestCase {
|
||||
|
||||
loggedSql = LoggedSqlCollector.stop();
|
||||
assertThat(loggedSql).hasSize(1);
|
||||
assertThat(loggedSql.get(0)).contains("delete from contact t0 where t0.first_name =");
|
||||
assertThat(loggedSql.get(0)).contains("delete from contact where first_name =");
|
||||
|
||||
|
||||
server.find(Contact.class).select("id").where().eq("firstName", "NotARealFirstName").delete();
|
||||
@@ -54,27 +54,35 @@ public class TestDeleteByQuery extends BaseTestCase {
|
||||
@Test
|
||||
public void testWithForUpdate() {
|
||||
|
||||
EbeanServer server = Ebean.getDefaultServer();
|
||||
if (server.getName().equals("mysql")) {
|
||||
// MySql does not the sub query selecting from the delete table
|
||||
return;
|
||||
}
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
server.find(Customer.class)
|
||||
.where().eq("name","FatsDomino")
|
||||
Ebean.find(Customer.class)
|
||||
.where().eq("name","Don Roberto")
|
||||
.query().setForUpdate(true)
|
||||
.delete();
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("delete from o_customer where name = ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void delete_queryString() {
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
Ebean.createQuery(Customer.class, "where name = :name")
|
||||
.setParameter("name","Don Roberto")
|
||||
.delete();
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("delete from o_customer where name = ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommit() {
|
||||
|
||||
EbeanServer server = Ebean.getDefaultServer();
|
||||
if (server.getName().equals("mysql")) {
|
||||
// MySql does not the sub query selecting from the delete table
|
||||
return;
|
||||
}
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Customer> all = Customer.find.all();
|
||||
@@ -85,10 +93,9 @@ public class TestDeleteByQuery extends BaseTestCase {
|
||||
|
||||
Ebean.save(contact);
|
||||
|
||||
Ebean.find(Contact.class).select("id").where().eq("firstName", "DelByQueryFirstName").delete();
|
||||
Ebean.find(Contact.class).where().eq("firstName", "DelByQueryFirstName").delete();
|
||||
|
||||
Contact contactFind = Ebean.find(Contact.class, contact.getId());
|
||||
assertThat(contactFind).isNull();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user