question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

udpate failed with escapeFn problem

See original GitHub issue

When run test

import { Database, DataTypes, Model } from 'https://deno.land/x/denodb/mod.ts';
import { hash } from "https://deno.land/x/bcrypt/mod.ts";
import { assertEquals } from "../testdeps.ts";
import { mysqlOptions} from "../config/db.ts";

class User extends Model {
  static table = 'user';
  static timestamps = true;

  static fields = {
    id: {
      primaryKey: true,
      autoIncrement: true,
    },
    name: DataTypes.STRING,
    password: DataTypes.STRING,
    email: DataTypes.STRING,
  };
}
const db = new Database('mysql', mysqlOptions);
db.link([User ]);
await db.sync({ drop: false });

Deno.test("model: create", async () => {
  const password = await hash('20090909');
  const data = await User.create({
    name: 'test',
    password,
    email: 'test@qq.com'
  })
  assertEquals(data.affectedRows, 1)
});

Deno.test("model: update", async () => {
  const record = await User.where('id', 1).update({name: 'deno'})
  assertEquals(record.name, 'deno')
});

db.close()

Record was created, but when update, got error like this

model: update
ReferenceError: Buffer is not defined
    at escapeFn (https://deno.land/x/dex/lib/query/string.js:44:16)
    at Client_MySQL.finalEscape [as _escapeBinding] (https://deno.land/x/dex/lib/query/string.js:18:12)
    at https://deno.land/x/dex/lib/client.js:151:19
    at String.replace (<anonymous>)
    at Client_MySQL._formatQuery (https://deno.land/x/dex/lib/client.js:143:16)
    at https://deno.land/x/dex/lib/interface.js:13:28
    at Array.map (<anonymous>)
    at Builder.Target.toQuery (https://deno.land/x/dex/lib/interface.js:12:8)
    at Builder.toString (https://deno.land/x/dex/lib/query/builder.js:68:17)
    at SQLTranslator.translateToQuery (https://deno.land/x/denodb/lib/translators/sql-translator.ts:209:25)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
eveningkidcommented, Jun 17, 2020

Grand, I am glad you like it Chaim 😃

Well, as it seems the issue has been solved, I will close the issue for now.

@linuxing3 do not hesitate to reopen it if your issue is still not fixed.

Other than that, have a great day guys

1reaction
ChaimF90commented, Jun 17, 2020

that worked! Thanks! Love this library btw

Read more comments on GitHub >

github_iconTop Results From Across the Web

Escape From Tarkov Game update installation error ... - Reddit
Escape From Tarkov Game update installation error (read everything in the error message) Open task manager and close everything that is BSG, ...
Read more >
Escape from Tarkov Error checking the launcher update fix
When Escape from Tarkov says there's an error checking the launcher update, it's typically due to server outages. The launcher will usually say ......
Read more >
Game update installation error fixed - Escape from Tarkov ...
Follow me on twitter: https://twitter.com/ditechgamingUse my code in the item shop: Ditech-Gaming.
Read more >
Escape literal used in the update query does not ... - GitHub
Caused by: java.lang.IllegalArgumentException: MismatchedTokenException(-1!=39) at org.jdbi.v3.core.internal.lexer.DefineStatementLexer.
Read more >
Are you getting a Content Update Pop Up Error? — FarmVille 2
If you're experiencing an issue with the "Content Update", please force-close your app or follow the troubleshootings steps found on the links.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found