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

Installing extensions gives DB Error: syntax error #6

Open
petednz opened this issue Dec 15, 2016 · 10 comments
Open

Installing extensions gives DB Error: syntax error #6

petednz opened this issue Dec 15, 2016 · 10 comments

Comments

@petednz
Copy link

petednz commented Dec 15, 2016

When I tried to install this I got

DB Error: syntax error

$Fatal Error Details = Array ( [callback] => Array ( [0] => CRM_Core_Error [1] => handle ) [code] => -2 [message] => DB Error: syntax error [mode] => 16 [debug_info] => CREATE TRIGGER civicrm_civirebux_configuration_after_insert after insert ON civicrm_civirebux_configuration FOR EACH ROW BEGIN IF ( @civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0 ) THEN INSERT INTO log_civicrm_civirebux_configuration (id, name, renderer, aggregator, vals, rows, cols, time, desc, type, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.name, NEW.renderer, NEW.aggregator, NEW.vals, NEW.rows, NEW.cols, NEW.time, NEW.desc, NEW.type, CONNECTION_ID(), @civicrm_user_id, 'insert'); END IF; END [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, type, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.name, NEW' at line 1] [type] => DB_Error [user_info] => CREATE TRIGGER civicrm_civirebux_configuration_after_insert after insert ON civicrm_civirebux_configuration FOR EACH ROW BEGIN IF ( @civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0 ) THEN INSERT INTO log_civicrm_civirebux_configuration (id, name, renderer, aggregator, vals, rows, cols, time, desc, type, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.name, NEW.renderer, NEW.aggregator, NEW.vals, NEW.rows, NEW.cols, NEW.time, NEW.desc, NEW.type, CONNECTION_ID(), @civicrm_user_id, 'insert'); END IF; END [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, type, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.name, NEW' at line 1] [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="CREATE TRIGGER civicrm_civirebux_configuration_after_insert after insert ON civicrm_civirebux_configuration FOR EACH ROW BEGIN IF ( @civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0 ) THEN INSERT INTO log_civicrm_civirebux_configuration (id, name, renderer, aggregator, vals, rows, cols, time, desc, type, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.name, NEW.renderer, NEW.aggregator, NEW.vals, NEW.rows, NEW.cols, NEW.time, NEW.desc, NEW.type, CONNECTION_ID(), @civicrm_user_id, 'insert'); END IF; END [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, type, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.name, NEW' at line 1]"] )

refreshing the Extension page shows it as 'enabled'

At /civicrm/civirebux I get

DB Constraint Violation - possibly contact_id should possibly be marked as mandatory for this API. If so, please raise a bug report.

$Fatal Error Details = array(3) { ["message"]=> string(132) "DB Constraint Violation - possibly contact_id should possibly be marked as mandatory for this API. If so, please raise a bug report." ["code"]=> NULL ["exception"]=> object(CiviCRM_API3_Exception)#218 (8) { ["extraParams":"CiviCRM_API3_Exception":private]=> array(4) { ["error_code"]=> string(13) "no such field" ["tip"]=> string(62) "add debug=1 to your API call to have more info about the error" ["is_error"]=> int(1) ["error_message"]=> string(132) "DB Constraint Violation - possibly contact_id should possibly be marked as mandatory for this API. If so, please raise a bug report." } ["message":protected]=> string(132) "DB Constraint Violation - possibly contact_id should possibly be marked as mandatory for this API. If so, please raise a bug report." ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(74) "//sites/all/modules/civicrm/api/api.php" ["line":protected]=> int(45) ["trace":"Exception":private]=> array(9) { [0]=> array(4) { ["file"]=> string(114) "//sites/default/civicrm/extensions/org.civicrm.civirebux/CRM/Civirebux/Data.php" ["line"]=> int(24) ["function"]=> string(12) "civicrm_api3" ["args"]=> array(3) { [0]=> &string(12) "Contribution" [1]=> &string(3) "get" [2]=> &array(4) { ["sequential"]=> int(1) ["api.Contribution.get"]=> array(0) { } ["return"]=> string(433) "id,contact_id,financial_type_id,contribution_page_id,payment_instrument_id,receive_date,non_deductible_amount,total_amount,fee_amount,net_amount,trxn_id,invoice_id,currency,cancel_date,cancel_reason,receipt_date,thankyou_date,source,amount_level,contribution_recur_id,is_test,is_pay_later,contribution_status_id,address_id,check_number,campaign_id,creditnote_id,tax_amount,revenue_recognition_date,display_name,sort_name,contact_type" ["options"]=> array(2) { ["sort"]=> string(6) "id ASC" ["limit"]=> int(0) } } } } [1]=> array(6) { ["file"]=> string(121) "//sites/default/civicrm/extensions/org.civicrm.civirebux/CRM/Civirebux/Page/Report.php" ["line"]=> int(52) ["function"]=> string(19) "getContributionData" ["class"]=> string(18) "CRM_Civirebux_Data" ["type"]=> string(2) "::" ["args"]=> array(0) { } } [2]=> array(6) { ["file"]=> string(82) "//sites/all/modules/civicrm/CRM/Core/Invoke.php" ["line"]=> int(310) ["function"]=> string(3) "run" ["class"]=> string(25) "CRM_Civirebux_Page_Report" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> &array(2) { [0]=> string(7) "civicrm" [1]=> string(9) "civirebux" } [1]=> &NULL } } [3]=> array(6) { ["file"]=> string(82) "//sites/all/modules/civicrm/CRM/Core/Invoke.php" ["line"]=> int(84) ["function"]=> string(7) "runItem" ["class"]=> string(15) "CRM_Core_Invoke" ["type"]=> string(2) "::" ["args"]=> array(1) { [0]=> &array(13) { ["id"]=> string(3) "429" ["domain_id"]=> string(1) "1" ["path"]=> string(17) "civicrm/civirebux" ["title"]=> string(6) "Report" ["access_callback"]=> array(2) { [0]=> string(19) "CRM_Core_Permission" [1]=> string(9) "checkMenu" } ["access_arguments"]=> array(2) { [0]=> array(1) { [0]=> string(24) "access CiviCRM Civirebux" } [1]=> string(3) "and" } ["page_callback"]=> string(25) "CRM_Civirebux_Page_Report" ["breadcrumb"]=> array(1) { [0]=> array(2) { ["title"]=> string(7) "CiviCRM" ["url"]=> string(16) "/civicrm?reset=1" } } ["is_ssl"]=> string(1) "0" ["weight"]=> string(1) "1" ["type"]=> string(1) "1" ["page_type"]=> string(1) "0" ["page_arguments"]=> bool(false) } } } [4]=> array(6) { ["file"]=> string(82) "//sites/all/modules/civicrm/CRM/Core/Invoke.php" ["line"]=> int(52) ["function"]=> string(7) "_invoke" ["class"]=> string(15) "CRM_Core_Invoke" ["type"]=> string(2) "::" ["args"]=> array(1) { [0]=> &array(2) { [0]=> string(7) "civicrm" [1]=> string(9) "civirebux" } } } [5]=> array(6) { ["file"]=> string(84) "//sites/all/modules/civicrm/drupal/civicrm.module" ["line"]=> int(448) ["function"]=> string(6) "invoke" ["class"]=> string(15) "CRM_Core_Invoke" ["type"]=> string(2) "::" ["args"]=> array(1) { [0]=> &array(2) { [0]=> string(7) "civicrm" [1]=> string(9) "civirebux" } } } [6]=> array(2) { ["function"]=> string(14) "civicrm_invoke" ["args"]=> array(1) { [0]=> &string(9) "civirebux" } } [7]=> array(4) { ["file"]=> string(54) "//includes/menu.inc" ["line"]=> int(527) ["function"]=> string(20) "call_user_func_array" ["args"]=> array(2) { [0]=> &string(14) "civicrm_invoke" [1]=> &array(1) { [0]=> string(9) "civirebux" } } } [8]=> array(4) { ["file"]=> string(46) "//index.php" ["line"]=> int(21) ["function"]=> string(27) "menu_execute_active_handler" ["args"]=> array(0) { } } } ["previous":"Exception":private]=> NULL } }

and various other errors including

Report Error Extension could not send since no email address was set.

$backTrace = #0 //sites/all/modules/civicrm/CRM/Core/Error.php(451): CRM_Core_Error::backtrace("backTrace", TRUE) #1 //sites/all/modules/civicrm/CRM/Core/Invoke.php(55): CRM_Core_Error::handleUnhandledException(Object(CiviCRM_API3_Exception)) #2 //sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:2)) #3 internal function: civicrm_invoke("civirebux") #4 //includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:1)) #5 //index.php(21): menu_execute_active_handler() #6 {main}
S

@petednz
Copy link
Author

petednz commented Dec 15, 2016

This is on a 4.7.14 on drupal

@petednz
Copy link
Author

petednz commented Dec 15, 2016

I tried various things, including uninstalling, turning off logging, reinstalling (no repitition of first error) but i get the same outcome at civicrm/rebux

@ypranay ypranay closed this as completed Feb 7, 2017
@petednz
Copy link
Author

petednz commented Feb 7, 2017

I see you closed this but don't see any comments as to whether the issue was fixed, and nor do i spot any changes to the code to indicate what has been done. Can you please clarify

@ypranay ypranay reopened this Feb 7, 2017
@ypranay
Copy link
Owner

ypranay commented Feb 7, 2017

My bad! It happened by mistake. I will have a closer look at the issue by EOD.

@laryn
Copy link
Contributor

laryn commented Feb 13, 2017

I've had the same problem in the past. Just tried it again and the same issue occurs.

See also:

@petednz
Copy link
Author

petednz commented Feb 24, 2017

@ypranay any chance you can look in near future?

@laryn
Copy link
Contributor

laryn commented Mar 9, 2017

@ypranay Which version of MySQL did you develop on?

@xurizaemon
Copy link

xurizaemon commented Apr 10, 2017

DESC is a reserved word in MySQL. In CRM/Civirebux/Upgrader.php this is used as a column name.

MySQL permits this because of the backticks used, but (if CiviCRM's Data Logging is enabled?) CiviCRM later tries to generate triggers using the column name, which generates an SQL error.

IMO it's good practice to avoid backticks, then you identify reserved words more quickly and don't end up with them causing problems down the track.

@davidjosephhayes
Copy link

#7

@davejenx
Copy link

I fixed the issue in Civi core that causes this error: CRM-20443 SQL syntax error creating logging triggers if column name is reserved word.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants