format-sql
format-sql copied to clipboard
TypeError: expected a character buffer object
File "/usr/local/bin/format-sql", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/format_sql/main.py", line 83, in main
_write_back(filename, lines, args.dry_run)
File "/usr/local/lib/python2.7/dist-packages/format_sql/main.py", line 148, in _write_back
f.write(lines)
TypeError: expected a character buffer object
I've tried this with several files, including one ruby file with embedded SQL and then just with the SQL itself. Any insight into this? I'm just surprised that others aren't getting the same error.
I get this error too. The troubling part is that when this happens it truncates the source file:
~/code/ruby >ll /tmp/x.sql
-rw-r--r-- 1 skyes wheel 965B Sep 6 15:05 /tmp/x.sql
~/code/ruby/gettxt-test >format-sql /tmp/x.sql
/tmp/x.sql
Traceback (most recent call last):
File "/usr/local/bin/format-sql", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/format_sql/main.py", line 83, in main
_write_back(filename, lines, args.dry_run)
File "/usr/local/lib/python2.7/site-packages/format_sql/main.py", line 148, in _write_back
f.write(lines)
TypeError: expected a string or other character buffer object
~/code/ruby/gettxt-test >ll /tmp/x.sql
-rw-r--r-- 1 skyes wheel 0B Sep 6 15:06 /tmp/x.sql
😱 🙀 :rage4:
~/code/ruby >python --version
Python 2.7.11
~/code/ruby >format-sql --version
format-sql 0.12.0
Ran into this as well. I created https://github.com/paetzke/format-sql/pull/6 which I believe fixes the issue.