pymysql.err.InternalError: (1292, u"Truncated incorrect INTEGER value: '60 days'")

Executing erpnext.patches.v11_0.rename_field_max_days_allowed in mydomain.com (c578196c85e90dce)
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
“main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 227, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 38, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 83, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v11_0/rename_field_max_days_allowed.py”, line 11, in execute
frappe.db.sql_ddl(“”“ALTER table tabLeave Type modify max_days_allowed int(8) NOT NULL”“”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 276, in sql_ddl
self.sql(query, debug=debug)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 210, in sql
self._cursor.execute(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 516, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 727, in _read_query_result
result.read()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1066, in read
first_packet = self.connection._read_packet()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 683, in _read_packet
packet.check_error()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.InternalError: (1292, u"Truncated incorrect INTEGER value: ‘60 days’")

please help. :cold_sweat:

This is happening while executing the patch - erpnext.patches.v11_0.rename_field_max_days_allowed

The patch is trying to modify the column as Integer, but you have non-integer values in the table `tabLeave Type’, column max_days_allowed. (In your case it says ‘60 days’ which cannot be converted to integer)

Write a query to change the values in this column to integer values and run the patch again (or update or migrate - whichever you were doing when you got this error)

how to write query , i`m new please advise

thanks

From the frappe-bench folder type the following
bench mariadb
select name, max_days_allowed from tabLeave Type;

You will see a bunch of rows returned. For each row that you dont see a integer value, perform the following query -
update tabLeave Type set max_days_allowed = 60 where name=‘name you got from the result’;

Replace 60 with the number that you think is right for you.

i got this

MariaDB [c578196c85e90dce]> select name, max_days_allowed from tabLeave Type;
ERROR 1146 (42S02): Table ‘c578196c85e90dce.tabLeave’ doesn’t exist

Sorry, I missed that. You have to type back quotes before and after the table name. As in tabLeave Type

To display the backtick character just, enclose the statement in ``` before and after

select name, max_days_allowed from `tabLeave Type`;
1 Like

MariaDB [c578196c85e90dce]> select name, max_days_allowed from tabLeave Type;
±------------------±-----------------+
| name | max_days_allowed |
±------------------±-----------------+
| Leave Without Pay | 0 |
| Maternity Leave | 60 days |
| Sick Leave | 0 |
±------------------±-----------------+
3 rows in set (0.00 sec)

here result i get how to replace it?@clarkej @kirthi

update tabLeave Type set max_days_allowed = 60 where name=‘Maternity Leave’;

 MariaDB [c578196c85e90dce]> update `tabLeave Type` set max_days_allowed = 60 where name = `Maternity Leave`;
ERROR 1054 (42S22): Unknown column 'Maternity Leave' in 'where clause'

get error.

ok this is the right command , successfuly write, thanks for help @kirthi @clarkej

MariaDB [c578196c85e90dce]> update `tabLeave Type` set max_days_allowed = 60 where name="Maternity Leave";
Query OK, 1 row affected (0.05 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [c578196c85e90dce]> select name, max_days_allowed from `tabLeave Type`;
+-------------------+------------------+
| name              | max_days_allowed |
+-------------------+------------------+
| Leave Without Pay | 0                |
| Maternity Leave   | 60               |
| Sick Leave        | 0                |
+-------------------+------------------+
3 rows in set (0.00 sec)