dibi icon indicating copy to clipboard operation
dibi copied to clipboard

FOR UPDATE doesn't work if it's not added after limit

Open dakorpar opened this issue 5 years ago • 1 comments

Version: 4.2.0

Bug Description

forUpdate doesn't work correct with fluent interface when after it we're calling fetch or fetchSingle. FOR UPDATE is added before limit and we get Sql exception

Steps To Reproduce

	$db->select('whatever')->from('table)
		->where('id = %i', $id)
		->forUpdate()
		->fetchSingle();

however this works:

	$db->select('whatever')->from('table)
		->where('id = %i', $id)
		->limit(1)
		->forUpdate()
		->fetchSingle();

dakorpar avatar Dec 23 '20 10:12 dakorpar

This would require change the limit() behavior in the Fluent, which would cause a BC break, so I don't want to deal with it at all…

dg avatar Jan 05 '21 21:01 dg