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

Index Mapping with Join #864

Closed
Hashiyama89 opened this issue Aug 14, 2019 · 1 comment
Closed

Index Mapping with Join #864

Hashiyama89 opened this issue Aug 14, 2019 · 1 comment
Labels

Comments

@Hashiyama89
Copy link

Describe the bug
When you use a join query, and want to map one field which exists in both tables, it doesn't work.

Information

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

Detail Code

If I do this, they cant find the index mappin 'books.id'
$result = $this->select( ['[>]photos' => ['id' => 'photo_id']] , [ 'books.id' => [ 'books.id [Int]', 'name', 'url' ]], ["books.id" => $ids]);

In this case, the field ID exists in photos and books, so the query crash.
$result = $this->select( ['[>]photos' => ['id' => 'photo_id']] , [ 'id' => [ 'books.id [Int]', 'name', 'url' ]], ["books.id" => $ids]);

@catfan
Copy link
Owner

catfan commented Aug 14, 2019

This is a bug and fixed it on cf25af9.

However, when joining table, all those column name should be with table name as prefix.

$this->select([
	'[>]photos' => ['id' => 'photo_id']
], [
	'books.id' => [
		'books.id [Int]',
		'photos.name',
		'photos.url'
	]
], [
	"books.id" => $ids
]);

@catfan catfan closed this as completed Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants