mantisbt-plugins / Query

This plugin will enable you to define multiple queries/scripts which: 1. can be run online (by admin) 2. can be scheduled in which case results are emailed to nominated recipients
1 stars 1 forks source link

Impossible to create a new Query definition #5

Closed dregad closed 4 months ago

dregad commented 4 months ago

Error details

APPLICATION ERROR 401 Database query failed. Error received from database was #1364: Field 'query_script' doesn't have a default value for the query: INSERT INTO mantis_plugin_Query_definitions_table ( query_name,query_type,query_lvl,query_desc ) VALUES ( 'Count bugs','Q', 'U','Count bugs').

Stack trace

# Filename Line Class Type Function Args
0 ./mantisbt/core/classes/DbQuery.class.php 301 - - trigger_error '401', 256
1 ./mantisbt/core/classes/DbQuery.class.php 796 DbQuery -> db_execute -1, -1
2 ./mantisbt/core/database_api.php 318 DbQuery :: compat_db_query 'INSERT INTO {plugin_Query_definitions} ( query_name,query_type,query_lvl,query_desc ) VALUES ( \'Count bugs\',\'Q\', \'U\',\'Count bugs\')', { }, -1, -1, true
3 ./Query/pages/query_add.php 15 - - db_query 'INSERT INTO {plugin_Query_definitions} ( query_name,query_type,query_lvl,query_desc ) VALUES ( \'Count bugs\',\'Q\', \'U\',\'Count bugs\')'
4 ./mantisbt/plugin.php 74 - - include '/mnt/c/Users/Regad/Documents/dev/Query/pages/query_add.php'

Table structure

mysql> desc mantis_plugin_Query_definitions_table;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| query_id     | int unsigned | NO   | PRI | NULL    | auto_increment |
| query_name   | varchar(100) | NO   |     |         |                |
| query_desc   | varchar(200) | NO   |     |         |                |
| query_type   | varchar(1)   | NO   |     |         |                |
| query_script | longtext     | NO   |     | NULL    |                |
| query_tables | longtext     | NO   |     | NULL    |                |
| query_joins  | longtext     | NO   |     | NULL    |                |
| query_fields | longtext     | NO   |     | NULL    |                |
| query_filter | longtext     | NO   |     | NULL    |                |
| query_order  | longtext     | NO   |     | NULL    |                |
| query_group  | longtext     | NO   |     | NULL    |                |
| query_sql    | longtext     | NO   |     | NULL    |                |
| query_lvl    | varchar(1)   | NO   |     |         |                |
+--------------+--------------+------+-----+---------+----------------+
13 rows in set (0.03 sec)

This is with a fresh install of Query plugin (v2.13).

The Same error was reported by @ZakharchukEduard in https://github.com/mantisbt-plugins/Query/issues/3#issuecomment-2107338672

dregad commented 4 months ago

Problem is, your INSERT query in query_add.php is only specifying 4 fields query_name,query_type,query_lvl,query_desc but the other fields in the table are all NOT NULL.

PR follows.