Skip to content

fix: Use fromJson method instead of fromDBJson in BulkImportUser #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Feb 28, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.google.gson.Gson;
import com.google.gson.JsonObject;

import io.supertokens.pluginInterface.RowMapper;
import io.supertokens.pluginInterface.bulkimport.BulkImportStorage.BulkImportUserStatus;
import io.supertokens.pluginInterface.bulkimport.BulkImportUser;
Expand Down Expand Up @@ -180,9 +183,18 @@ private static BulkImportUserRowMapper getInstance() {

@Override
public BulkImportUser map(ResultSet result) throws Exception {
return BulkImportUser.fromDBJson(result.getString("id"), result.getString("raw_data"),
BulkImportUserStatus.valueOf(result.getString("status")),
result.getLong("created_at"), result.getLong("updated_at"));
JsonObject flattenedJson = new JsonObject();
flattenedJson.addProperty("id", result.getString("id"));
flattenedJson.addProperty("status", result.getString("status"));
flattenedJson.addProperty("createdAt", result.getString("created_at"));
flattenedJson.addProperty("updatedAt", result.getString("updated_at"));

JsonObject rawData = new Gson().fromJson(result.getString("raw_data"), JsonObject.class);
for (var entry : rawData.entrySet()) {
flattenedJson.add(entry.getKey(), entry.getValue());
}

return BulkImportUser.fromJson(flattenedJson);
}
}
}