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

Bug: table.Array in first() ... - and complex primary keys! ;-) #3394

Closed
nowackipawel opened this issue Jul 23, 2020 · 2 comments
Closed

Bug: table.Array in first() ... - and complex primary keys! ;-) #3394

nowackipawel opened this issue Jul 23, 2020 · 2 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@nowackipawel
Copy link
Contributor

I will try to fix it in next days because I know exactly where the error is.
No issue:


				$user_exam = (new \User2DrivingSchoolModel())
					->where('usr2drs_usr_id', $usr_id)
					->where('usr2drs_drs_id', (int)$this->request->getGet('drs_id'))
					->groupStart()->where('usr2drs_dlc_id IS NULL', null, false)->orWhere('usr2drs_dlc_id', strtoupper($dlc_id_or_qus_id))->groupEnd()
					->orderBy('usr2drs_dlc_id', 'ASC')
					->first();

Issue exists:


				$user_exam = (new \User2DrivingSchoolModel())
					->where('usr2drs_usr_id', $usr_id)
					->where('usr2drs_drs_id', (int)$this->request->getGet('drs_id'))
					->groupStart()->where('usr2drs_dlc_id IS NULL', null, false)->orWhere('usr2drs_dlc_id', strtoupper($dlc_id_or_qus_id))->groupEnd()
					->first();

and error:

CRITICAL - 2020-07-23 17:49:18 --> Unknown column 't_user2t_driving_school.Array' in 'order clause'
#0 /home/zdamy/site/system/Database/MySQLi/Connection.php(330): mysqli->query()
#1 /home/zdamy/site/system/Database/BaseConnection.php(738): CodeIgniter\Database\MySQLi\Connection->execute()
#2 /home/zdamy/site/system/Database/BaseConnection.php(666): CodeIgniter\Database\BaseConnection->simpleQuery()
#3 /home/zdamy/site/system/Database/BaseBuilder.php(1820): CodeIgniter\Database\BaseConnection->query()
#4 /home/zdamy/site/system/Model.php(516): CodeIgniter\Database\BaseBuilder->get()
#5 /home/zdamy/site/app/Controllers/Site/CPracticeTest.php(156): CodeIgniter\Model->first()
#6 /home/zdamy/site/system/CodeIgniter.php(910): App\Controllers\Site\CPracticeTest->index()
#7 /home/zdamy/site/system/CodeIgniter.php(398): CodeIgniter\CodeIgniter->runController()
#8 /home/zdamy/site/system/CodeIgniter.php(306): CodeIgniter\CodeIgniter->handleRequest()
#9 /home/zdamy/site/public/index.php(45): CodeIgniter\CodeIgniter->run()
#10 {main}

It is related to this part:


		// Some databases, like PostgreSQL, need order
		// information to consistently return correct results.
		if (empty($builder->QBOrderBy) && ! empty($this->primaryKey))
		{
			$builder->orderBy($this->table . '.' . $this->primaryKey, 'asc');
		}

of first() method .

@nowackipawel nowackipawel added the bug Verified issues on the current code behavior or pull requests that will fix them label Jul 23, 2020
@nowackipawel nowackipawel changed the title Bug: Bug: table.Array in first() ... - and complex primary keys! ;-) Jul 23, 2020
@michalsn
Copy link
Member

michalsn commented Aug 3, 2020

I'm pretty sure that your primary key is an array. Sorry, but composite primary keys are not supported at this moment.

I'm closing this, but feel free to continue the conversation.

@michalsn michalsn closed this as completed Aug 3, 2020
@nowackipawel
Copy link
Contributor Author

#4120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

2 participants