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

wrong where-statement output when comparing the value of columns #1014

Closed
Fluit opened this issue Sep 17, 2021 · 3 comments
Closed

wrong where-statement output when comparing the value of columns #1014

Fluit opened this issue Sep 17, 2021 · 3 comments

Comments

@Fluit
Copy link

Fluit commented Sep 17, 2021

Information

  • Version of Medoo: 2.1.2
  • Type of Database (MySQL, MSSQL, SQLite...): MySQL
  • System (Liunx\Windows\Mac): Windows

Describe the Problem
According to the documentation Columns Relationship I use ["fld1[=]fld2"] as a condition for comparing the values of the 2 columns. Instead of WHERE fld1 = fld2 i get WHERE fld1 = "fld1[=]fld2"

Detail Code
$this->Db->select('tbl1', ["[><]tbl2" => ['id' => 'tbl1_id']], ['fld1', 'fld2', ....], ["fld1[=]fld2"]) results in sql-string SELECT * tbl1 INNER JOIN tbl2 ON tbl1.id = tbl2.tb1_id WHERE fld1 = "fld1[=]fld2"
FYI: fld1 & fld2 are unique fieldnames in tbl2!
Even changing the where-array in ['tbl2.fld1[=]tbl2.fld2"] makes no difference.

It looks like the second part of the condition is not quoted correctly.

Expected output
is should be ... SELECT * tbl1 INNER JOIN tbl2 ON tbl1.id = tbl2.tb1_id WHERE tbl2.fld1 = tbl2.fld2"

@Fluit
Copy link
Author

Fluit commented Sep 17, 2021

A workaround is using Medoo;;raw statement: ['fld1' => \Medoo\Medoo::raw('<tbl2.fld2>')]

@catfan
Copy link
Owner

catfan commented Sep 17, 2021

That's a bug. Fixed it on 6f9a6c6.

@Fluit
Copy link
Author

Fluit commented Sep 27, 2021

Tested and approved!

thanks.

@catfan catfan closed this as completed Oct 9, 2021
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

2 participants