Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Error when updating record - Error 501 #259

Open
dnnbuddy opened this issue Nov 26, 2019 · 3 comments
Open

Error when updating record - Error 501 #259

dnnbuddy opened this issue Nov 26, 2019 · 3 comments

Comments

@dnnbuddy
Copy link

Hi,

When we update records we always see the following error message in the console.

Error: http://google.github.io/lovefield/error_lookup/src/error_lookup.html?c=501

But the strange thing is after few edit efforts(few times of edits) error message won't appear afterward. Everything is working as expected. But with the initial page load, we always see the error message in the console.

Even with the above error message record is successfully getting updated as expected.

Please advise on any clue on how to proceed with this.

Thanks.
Thusitha

@freshp86
Copy link
Contributor

The error indicates that a parametrized query is executed without all parameters having been specified. Do you have such queries in your code?

@dnnbuddy
Copy link
Author

dnnbuddy commented Nov 27, 2019

We have parameterized queries and we follow the following pattern. Even this simple update throws the same error.

var t = this._tagTable;

var q = db.
    update(t).
    set(t._mode, lf.bind(1)).
    where(t.seq.eq(lf.bind(0)));

q.bind([seq, mode]).exec();

@arthurhsu
Copy link
Contributor

arthurhsu commented Jan 19, 2020

Can you post complete code snippet?

I run the following code based on the TODO demo with no problem.

<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Minimal example of using Lovefield</title>
    <script src="lovefield.min.js"></script>
  </head>
  <body>
    <script>

var schemaBuilder = lf.schema.create('todo', 1);

schemaBuilder.createTable('Item').
    addColumn('id', lf.Type.INTEGER).
    addColumn('description', lf.Type.STRING).
    addColumn('deadline', lf.Type.DATE_TIME).
    addColumn('done', lf.Type.BOOLEAN).
    addPrimaryKey(['id']).
    addIndex('idxDeadline', ['deadline'], false, lf.Order.DESC);

var todoDb;
var item;
schemaBuilder.connect().then(function(db) {
  todoDb = db;
  item = db.getSchema().table('Item');
  var row = item.createRow({
    'id': 1,
    'description': 'Get a cup of coffee',
    'deadline': new Date(),
    'done': false
  });

  return db.insertOrReplace().into(item).values([row]).exec();
}).then(function() {
  var q = todoDb
      .update(item)
      .set(item.description, lf.bind(1))
      .where(item.id.eq(lf.bind(0)));
  return q.bind([1, 'hohoho']).exec();
}).then(function() {
  return todoDb.select().from(item).where(item.done.eq(false)).exec();
}).then(function(results) {
  results.forEach(function(row) {
    console.log(row['description'], 'before', row['deadline']);
    document.body.textContent =
        row['description'] + ' before ' + row['deadline'];
  });
});

    </script>
  </body>
</html>

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

No branches or pull requests

3 participants