Skip to content
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

Key field name limitation #130

Open
mvoros-rs opened this issue Oct 28, 2024 · 0 comments
Open

Key field name limitation #130

mvoros-rs opened this issue Oct 28, 2024 · 0 comments

Comments

@mvoros-rs
Copy link

Hi,

is there currently a limitation that the ID field of entity must be called "ID". I have an entity where the key field is called "id" (lowercase). This does not seem to work. The problem already seems to be here:

async function track_changes (req) {
  let diff = await req.diff()
  if (!diff) return

  let target = req.target
  let compContext = null;
  let entityKey = diff.ID  <----

The diff object is correctly calculated and there is a key in the property diff.id. But entityKey stays undefined due to id not being in upper case. Fixing this problem allows correct association of change with the entity.

But there are more places later where it fails.

Here, the ID is again hard coded.

function _trackedChanges4 (srv, target, diff) {
  const template = getTemplate("change-logging", srv, target, { pick: e => e['@changelog'] })
  if (!template.elements.size) return

  const changes = []
  diff._path = `${target.name}(${diff.ID})`

And later here as queryKey is not provided and the default value is used.
const getCurObjFromDbQuery = async function (entityName, queryVal, /**optional*/ queryKey='ID') {

I don't see this limitation being document anywhere. Is there a plan to extend this to have more flexible support of entities? If not, can this be at least documented and that only entities with key ID are supported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant