? ? Pending

User tests: Successful: Unsuccessful:

avatar HLeithner
HLeithner
29 May 2019

This PR tries to move the SQL custom field into a prepared statement, at least for the values part.

Summary of Changes

Updated SQL queries to prepared statements and made some cleanups around the queries.

Testing Instructions

  • Create a SQL custom field
  • Use several SQL queries in the custom field
  • check the frontend if the expected result could be found.

Expected result

Nothing changed.

avatar HLeithner HLeithner - open - 29 May 2019
avatar HLeithner HLeithner - change - 29 May 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 29 May 2019
Category Front End Plugins
avatar franz-wohlkoenig franz-wohlkoenig - change - 30 May 2019
Title
Add prepared statements for plg_fields_sql
[4.0] Add prepared statements for plg_fields_sql
avatar franz-wohlkoenig franz-wohlkoenig - edited - 30 May 2019
avatar HLeithner HLeithner - change - 9 Jun 2019
Labels Added: ?
avatar HLeithner
HLeithner - comment - 11 Jul 2019

Hope it's ok now @shanginn

avatar SharkyKZ
SharkyKZ - comment - 15 Jul 2019

It's still running an empty query.

1231ad9 19 Oct 2019 avatar HLeithner cs
avatar Quy Quy - change - 11 Nov 2019
Labels Added: ?
avatar HLeithner HLeithner - change - 27 Dec 2019
Labels Added: ?
Removed: ?
avatar HLeithner HLeithner - change - 27 Dec 2019
Labels Added: ?
Removed: ?
avatar HLeithner
HLeithner - comment - 27 Dec 2019

I found another problem, if $db->setQuery($query) is not in the try catch construct and the sql query is broken (for example $value is 0 which is not possible any longer) then joomla raise an exception on setQuery because we do a Driver->prepareStatement() in this function.

This is already true for the current implementation...

Also I'm not sure how the query with the HAVING clause could fail and the original query would work.

if you have a query

select id as value, title as text from #__content

then the having variant will always work

select id as value, title as text from #__content HAVING VALUE IN ('1');

if the query fails because no value column exists it will also fail without the having clause because we expect a value column...

What do I miss?

avatar SharkyKZ
SharkyKZ - comment - 30 Dec 2019

We don't know what kind of query is entered so adding anything could break it. For example if entered query ends in ; the code already fails as it results in this:

select id as value, title as text from #__content; HAVING VALUE IN ('1');

Another case, the query could already have a HAVING clause.

avatar SharkyKZ
SharkyKZ - comment - 30 Dec 2019

We could avoid the first scenario by loading SQL into the query object and using the API to build having clause instead of directly manipulating SQL.

avatar HLeithner
HLeithner - comment - 30 Dec 2019

We could avoid the first scenario by loading SQL into the query object and using the API to build having clause instead of directly manipulating SQL.

Jquery doesn't split the query into parts.

So we should keep it this way until someone builds the ultimate query builder ;)

avatar SharkyKZ
SharkyKZ - comment - 31 Dec 2019

Hm, you're right. Although we could still use query methods for HAVING clause. But it's fine either way. Just lowercase and quote value please because it's a column name.

avatar HLeithner HLeithner - change - 1 Jan 2020
Labels Added: ?
Removed: ?
avatar SharkyKZ SharkyKZ - test_item - 3 Jan 2020 - Tested successfully
avatar SharkyKZ
SharkyKZ - comment - 3 Jan 2020

I have tested this item successfully on a952aed


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/25056.

avatar Quy Quy - test_item - 4 Jan 2020 - Tested successfully
avatar Quy
Quy - comment - 4 Jan 2020

I have tested this item successfully on a952aed


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/25056.

avatar Quy Quy - change - 4 Jan 2020
Status Pending Ready to Commit
avatar Quy
Quy - comment - 4 Jan 2020

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/25056.

avatar infograf768 infograf768 - change - 4 Jan 2020
Labels Added: ?
Removed: ?
avatar rdeutz rdeutz - change - 4 Jan 2020
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-01-04 14:14:22
Closed_By rdeutz
avatar rdeutz rdeutz - close - 4 Jan 2020
avatar rdeutz rdeutz - merge - 4 Jan 2020

Add a Comment

Login with GitHub to post a comment