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

What is the problem with your ? and ?? parameters? #164

Open
suchislife801 opened this issue Oct 23, 2023 · 2 comments
Open

What is the problem with your ? and ?? parameters? #164

suchislife801 opened this issue Oct 23, 2023 · 2 comments

Comments

@suchislife801
Copy link

suchislife801 commented Oct 23, 2023

Your examples are so small...

I have no idea how to execute an UPDATE query with a WHERE clause. It keeps thinking field values are field names. No documentation anywhere to learn from. Just 5 little dinky examples on your main page for people who are not really serious. You help section is soooo lacking...

WHY DOESN'T THIS WORK?

  const sqlUpdateCompany: string = 
  `UPDATE tblCompanies 
    SET 
      startDate = ?, 
      name = ?, 
      owner = ?, 
      status = ?, 
      ein = ?, 
      taxForm = ?, 
      industry = ?, 
      stateLicenseNumber = ?, 
      address1 = ?, 
      city = ?, 
      state = ?, 
      postalCode = ?, 
      email = ?, 
      phone = ?, 
      url = ?, 
      notes = ?
    WHERE 
      id = ?`;

  // EXECUTE QUERY
  const sqlUpdateCompanyResult = await MYSQL_CONN.execute(sqlUpdateCompany, [
    reqBody.params.startDate,
    reqBody.params.name,
    reqBody.params.owner,
    reqBody.params.status,
    reqBody.params.ein,
    reqBody.params.taxForm,
    reqBody.params.industry,
    reqBody.params.stateLicenseNumber,
    reqBody.params.address1,
    reqBody.params.city,
    reqBody.params.state,
    reqBody.params.postalCode,
    reqBody.params.email,
    reqBody.params.phone,
    reqBody.params.url,
    reqBody.params.notes,
    reqBody.params.id
  ]);
Error: Unknown column '2023-01-01' in 'field list'

Why does it think the the value of startDate is the field name in the database?

@lideming
Copy link
Collaborator

Seems to be the ANSI_QUOTES mode (MySQL docs: https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_ansi_quotes).

Currently the sql-builder module uses double quotes " for string values. (issue: manyuanrong/sql-builder#15)

@Samermadieh
Copy link

Samermadieh commented Oct 11, 2024

@lideming Thanks, removing "ANSI" from mysql mode string fixed the issue. However, I agree with @suchislife801 the examples and documentation needs to be more clear and advanced.

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

3 participants