Skip to content

Commit

Permalink
fix: sqlite unable to patch db
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Jan 16, 2025
1 parent 2ec818b commit bff9471
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.ISqlCommonConfig;
import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonConfig;
import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlUtils;
import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite.SqliteConfig;
import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope;
import java.sql.SQLException;
import java.sql.Statement;
Expand All @@ -21,7 +22,11 @@ public void patch(Statement stmt, ISqlCommonConfig config) throws SQLException {
var table = SqlUtils.mapTable(
DataScope.TABLE_INFORMATION, config instanceof SqlCommonConfig scc ? scc.tablePrefix() : "");

stmt.execute("UPDATE " + table + " SET " + FIELD_TABLE_VERSION + " = '1' LIMIT 1;");
if (config instanceof SqliteConfig) {
stmt.execute("UPDATE " + table + " SET " + FIELD_TABLE_VERSION + " = '1' ");
} else {
stmt.execute("insert into " + table + " values (" + FIELD_TABLE_VERSION + " = '1');");
}

if (config instanceof MysqlConfig mysqlConf) {
var uniInvTable = SqlUtils.mapTable(DataScope.UNIVERSAL_INVENTORY, mysqlConf.tablePrefix());
Expand Down

0 comments on commit bff9471

Please sign in to comment.