Browse Source

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>
main
Stephan Richter 1 day ago
parent
commit
84b22e9b94
  1. 5
      stock/src/main/java/de/srsoftware/umbrella/stock/SqliteDb.java

5
stock/src/main/java/de/srsoftware/umbrella/stock/SqliteDb.java

@ -1,6 +1,7 @@
/* © SRSoftware 2025 */ /* © SRSoftware 2025 */
package de.srsoftware.umbrella.stock; package de.srsoftware.umbrella.stock;
import static de.srsoftware.tools.Optionals.is0;
import static de.srsoftware.tools.Optionals.nullIfEmpty; import static de.srsoftware.tools.Optionals.nullIfEmpty;
import static de.srsoftware.tools.jdbc.Condition.equal; import static de.srsoftware.tools.jdbc.Condition.equal;
import static de.srsoftware.tools.jdbc.Condition.isNull; import static de.srsoftware.tools.jdbc.Condition.isNull;
@ -302,11 +303,11 @@ public class SqliteDb extends BaseDb implements StockDb {
@Override @Override
public DbLocation save(DbLocation location) { 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 if (location.id() == 0) { // new location
try { try {
var rs = insertInto(TABLE_LOCATIONS,OWNER,PARENT_LOCATION_ID,NAME,DESCRIPTION) 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(); .execute(db).getGeneratedKeys();
long id = 0; long id = 0;
if (rs.next()) id = rs.getLong(1); if (rs.next()) id = rs.getLong(1);

Loading…
Cancel
Save