I'm getting the following error when running cron:
PDOException: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near 'USING'.: SELECT TOP(100) t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_vocabulary} tv USING (vid) LEFT JOIN {xmlsitemap} x ON x.type = 'taxonomy_term' AND t.tid = x.id WHERE x.id IS NULL AND tv.machine_name IN (:bundles_0, :bundles_1, :bundles_2, :bundles_3) ORDER BY t.tid DESC; Array ( [:bundles_0] => audiences [:bundles_1] => xxxx[:bundles_2] => xxxx[:bundles_3] => xxxx) in xmlsitemap_taxonomy_xmlsitemap_index_links() (line 38 of C:\pathgoeshere\xmlsitemap\xmlsitemap_taxonomy\xmlsitemap_taxonomy.module).

The "USING" syntax isn't compatible with SQL Server.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

azinck’s picture

Status: Active » Needs review
FileSize
2.61 KB

I've refactored all the queries in xmlsitemap_taxonomy.module to use db_select().

Dave Reid’s picture

Status: Needs review » Needs work

That's strange that SQL server doesn't support USING() which is standard via SQL-99.

It would be easier to convert the queries to just use ON table1.field = table2.field rather than converting to DBTNG.

azinck’s picture

Issue summary: View changes

Yeah...I just figured we'd switch to DBTNG one query at a time, and since I was already looking at it...

I guess you won't take this as-is?

Dave Reid’s picture

+++ b/xmlsitemap_taxonomy/xmlsitemap_taxonomy.module
@@ -202,7 +209,8 @@ function xmlsitemap_taxonomy_get_term_depth(stdClass $term) {
-    if ($parent = db_query("SELECT parent FROM {taxonomy_term_hierarchy} WHERE tid = %d", $term->tid)->fetchField()) {
+
+    if ($parent = db_select('taxonomy_term_hierarchy', 'tth')->fields('tth', array('parent'))->condition('tth.tid', $term->tid)->execute()->fetchField()) {

This query does not need to be converted, but should be using a better placeholder of :tid instead of %d.

azinck’s picture

Status: Needs work » Needs review
FileSize
2.59 KB
791 bytes

Placeholder updated.

Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 4 year old patch in #5 to xmlsitemap_taxonomy.module does not apply to the latest xmlsitemap 7.x-2.x-dev and if still applicable needs a reroll.

Checking patch xmlsitemap_taxonomy/xmlsitemap_taxonomy.module...
Hunk #1 succeeded at 40 (offset 5 lines).
Hunk #2 succeeded at 217 (offset 8 lines).
error: while searching for:
 *   The number of nodes associated with the term.
 */
function xmlsitemap_taxonomy_get_node_count(stdClass $term) {
  // @todo Use db_rewrite_sql() w/ switch user.
  return db_query_range("SELECT COUNT(ti.nid) FROM {taxonomy_index} ti LEFT JOIN {node n} USING (nid) WHERE ti.tid = :tid AND n.status = 1", 0, 1, array(':tid' => $term->tid))->fetchField();
}

/**

error: patch failed: xmlsitemap_taxonomy/xmlsitemap_taxonomy.module:227
error: xmlsitemap_taxonomy/xmlsitemap_taxonomy.module: patch does not apply