Issue while updating document where auto-generated id's are getting generated again - V 2.2.1 #262
-
Issue while updating document where auto-generated id's are getting generated again. Here is how our model looks Library-Version: v2.2.1 const table = new Table({
name: "TestCrud",
client: client,
logger: true,
uuid: () => {
return ksuid.randomSync().string;
},
schema: {
format: "onetable:1.1.0",
version: "0.0.1",
indexes: {
primary: { hash: "pk", sort: "sk" },
gs1: { hash: "gs1pk", sort: "gs1sk" },
},
models: {
User: {
pk: { type: String, required:true },
sk: { type: String, value: "user#${id}" },
id: { type: String, uuid:true, required:true },
name: { type: String, required: true },
status: { type: String, default: "active" },
zip: { type: String },
gs1pk: { type: String, value: "sec#${name}" },
gs1sk: { type: String, value: "sec#${id}" },
},
},
params: {
isoDates: true,
timestamps: true,
},
},
}); From the above code snippet, we are using UUID generation using ksuid (library) Insert works fine. But when we try to update the record id using pk and sk, the Example: Record in DB has following values before update
After executing update statement:
Record in DB
So if you look at When we tried downgrading the library version to v1.8.0 it started working as expected. Can you suggest a workaround for this? thanks a lot. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We tried to reproduce your sample, but it wan't complete and our reproduction of it worked fine with 2.3. Looking at the code, setDefaults will not return without generating IDs if update is called without params exists: null. If you did not specify that, no IDs should be generated. Can you please create a reproducible test case as per the issue template description under issues that we can run. Please make it as minimal as possible with no external deps. |
Beta Was this translation helpful? Give feedback.
We tried to reproduce your sample, but it wan't complete and our reproduction of it worked fine with 2.3.
Looking at the code, setDefaults will not return without generating IDs if update is called without params exists: null. If you did not specify that, no IDs should be generated.
Can you please create a reproducible test case as per the issue template description under issues that we can run. Please make it as minimal as possible with no external deps.