-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[com_finder] - SQL change for removeOrphanNodes() and postgresql driver fix #12313
Conversation
bugfix for the postgres driver
fix for title and description fields of #__finder_links table the title filed is varchar 400 on mysql the descrpition need to be text
title and description fields for #__finder_links table
wrong file name
field title , description of #__finder_links table
this table does not exist // Optimize the terms mapping table. $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_links_terms')); $db->execute();
I did a setup with latest staging, testing data and 4 additional languages. After installation I went in Extensions > Database and it gives me this message: Table 'kp7cx_finder_links' does not have column 'description' with type text DEFAULT '' NOT NULL. (From file 3.6.3-2016-10-04.sql.) So I pressed the Fix-Button and I got this syntax error: So next I started the indexing process which went fine but at the end I got this syntax error: FEHLER: Syntaxfehler bei »t« LINE 1: DELETE t FROM "#finder_taxonomy" AS t LEFT JOIN "#... ^SQL=DELETE t FROM "#__finder_taxonomy" AS t LEFT JOIN "#__finder_taxonomy_map" AS m ON m.node_id = t.id WHERE t.parent_id > 1 AND m.link_id IS NULL Finally I did a search for "test" in the "Indexed Content" and this message appears (operator doesn´t exist: timestamp without timezone ...): FEHLER: Operator existiert nicht: timestamp without time zone ~~ unknown LINE 4: ...t%' OR "l"."url" LIKE '%test%' OR "l"."indexdate" LIKE '%te... ^ HINT: Kein Operator stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen.SQL=SELECT l.,"t"."title" AS "t_title" FROM "#__finder_links" AS "l" INNER JOIN "#__finder_types" AS "t" ON "t"."id" = "l"."type_id" WHERE ("l"."title" LIKE '%test%' OR "l"."url" LIKE '%test%' OR "l"."indexdate" LIKE '%test%') ORDER BY l.title ASC LIMIT 20 FEHLER: Operator existiert nicht: timestamp without time zone ~~ unknown LINE 4: ...t%' OR "l"."url" LIKE '%test%' OR "l"."indexdate" LIKE '%te... ^ HINT: Kein Operator stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen.SQL=SELECT COUNT() FROM "#__finder_links" AS "l" INNER JOIN "#__finder_types" AS "t" ON "t"."id" = "l"."type_id" WHERE ("l"."title" LIKE '%test%' OR "l"."url" LIKE '%test%' OR "l"."indexdate" LIKE '%test%') FEHLER: Operator existiert nicht: timestamp without time zone ~~ unknown LINE 4: ...t%' OR "l"."url" LIKE '%test%' OR "l"."indexdate" LIKE '%te... ^ HINT: Kein Operator stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen.SQL=SELECT COUNT(*) FROM "#__finder_links" AS "l" INNER JOIN "#__finder_types" AS "t" ON "t"."id" = "l"."type_id" WHERE ("l"."title" LIKE '%test%' OR "l"."url" LIKE '%test%' OR "l"."indexdate" LIKE '%test%') |
@waader the goals of this pr are more simple:
a lot of more work need to be done, but this PR only affect postgresql related files so no B/C |
I understand. So I repeated the test with the same setup but without the multilingual stuff. ad 1) let's run index content from Smart Search: Indexed Content: ad 2. let's save/create an article when the content finder plugin is enabled |
i'm currently investigating on it .... but i'm afraid that the needed changes to let it work at least with minimal feature should'nt be only on the Postgresql side ..... i'll updated you.... |
remove orphans
remove orphans
update sql fix
@waader can you retest ... |
@@ -329,11 +329,15 @@ public static function removeOrphanNodes() | |||
{ | |||
// Delete all orphaned nodes. | |||
$db = JFactory::getDbo(); | |||
$query = 'DELETE t' . | |||
$query = 'DELETE ' . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not make this query use JDatabaseQuery
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire thing would have to be rewritten as three query objects because there are a bunch of subqueries here.
use JDatabaseQuery
no cause i'm lazy 😄 |
|
||
$subquery1->clear() | ||
->select($db->quoteName('t.id')) | ||
->from($db->quoteName('#__finder_taxonomy') . ' AS t') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
->from($db->quoteName('#__finder_taxonomy', 't'))
😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the ON ?
->join('LEFT',$db->quoteName('#__finder_taxonomy_map', 'm') . 'ON ' ....)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i think so, but care the space before ON
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -416,7 +416,7 @@ public function index($item, $format = 'html') | |||
' ROUND(SUM(' . $db->quoteName('context_weight') . '), 8)' . | |||
' FROM ' . $db->quoteName('#__finder_tokens_aggregate') . | |||
' WHERE ' . $db->quoteName('map_suffix') . ' = ' . $db->quote($suffix) . | |||
' GROUP BY ' . $db->quoteName('term') . | |||
' GROUP BY ' . $db->quoteName('term') . ' ,' . $db->quoteName('term_id') . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
', ' instead of ' ,' ?
// Optimize the terms mapping table. | ||
$db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_links_terms')); | ||
$db->execute(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per my comment on your other PR, I think this should be #__finder_terms and so should be fixed rather than removed. Also, for completeness, there are other tables that should be optimised at the same time.
$subquery = $db->getQuery(true); | ||
$subquery1 = $db->getQuery(true); | ||
|
||
$subquery1->clear() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary to call clear() here because you get a fresh query object from getQuery(true) anyway. Same for the next two statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clear removes creating a new class instance. It's performance better to call clear
than to get a fresh query object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but there's no point in calling clear
on fresh query objects, which is what is being done here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh oops. My bad!
' AND m.link_id IS NULL'; | ||
$query = $db->getQuery(true); | ||
$subquery = $db->getQuery(true); | ||
$subquery1 = $db->getQuery(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I prefer the fluent style so I'd merge these three statements into the statements below.
reindex missing tables same as for mysql driver
removed unnecessary clear()
|
No space found after comma in function call
I have not tested this item. I created a category called "Test", then created an article in that category. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12313. |
I have tested this item ✅ successfully on fe8a684 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12313. |
I have tested this item ✅ successfully on fe8a684 installation/sql/postgresql/joomla.sql needs an update. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12313. |
@@ -0,0 +1,3 @@ | |||
ALTER TABLE "#__finder_links" ALTER COLUMN "title" TYPE character varying(400); | |||
ALTER TABLE "#__finder_links" ALTER COLUMN "description" TYPE text; | |||
ALTER TABLE "#__finder_links" ALTER COLUMN "description" SET NOT NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about default value '' or not for description?
RTC as 2 good testers. Note: last comment is This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12313. |
Pull Request for Issue #9478 .
Summary of Changes
title
,description
) for#__finder_links
tableremoveOrphanNodes()
sql rewrite and should be tested on MySQL/MariaDB tooTesting Instructions