bugfix: it was not possible to create new locations on the top level – this is now fixed
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.stock;
|
||||
|
||||
import static de.srsoftware.tools.Optionals.is0;
|
||||
import static de.srsoftware.tools.Optionals.nullIfEmpty;
|
||||
import static de.srsoftware.tools.jdbc.Condition.equal;
|
||||
import static de.srsoftware.tools.jdbc.Condition.isNull;
|
||||
@@ -302,11 +303,11 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
|
||||
@Override
|
||||
public DbLocation save(DbLocation location) {
|
||||
var parentId = location.parent() == 0 ? null : location.parent();
|
||||
var parentId = is0(location.parent()) ? null : location.parent();
|
||||
if (location.id() == 0) { // new location
|
||||
try {
|
||||
var rs = insertInto(TABLE_LOCATIONS,OWNER,PARENT_LOCATION_ID,NAME,DESCRIPTION)
|
||||
.values(location.owner().dbCode(),location.parent() == 0 ? null : parentId,location.name(),location.description())
|
||||
.values(location.owner().dbCode(),parentId,location.name(),location.description())
|
||||
.execute(db).getGeneratedKeys();
|
||||
long id = 0;
|
||||
if (rs.next()) id = rs.getLong(1);
|
||||
|
||||
Reference in New Issue
Block a user