coleifer / sqlite-web

Web-based SQLite database browser written in Python
MIT License
3.42k stars 339 forks source link

sqlite-web errors when trying to drop a column #131

Closed LunarTwilight closed 1 year ago

LunarTwilight commented 1 year ago
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.10/dist-packages/sqlite_web/sqlite_web.py", line 248, in inner
    return fn(table, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/sqlite_web/sqlite_web.py", line 347, in drop_column
    migrate(migrator.drop_column(table, name))
  File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 886, in migrate
    operation.run()
  File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 164, in run
    self._handle_result(method(*self.args, **kwargs))
  File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 155, in _handle_result
    result.run()
  File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 164, in run
    self._handle_result(method(*self.args, **kwargs))
  File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 172, in inner
    return fn(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 723, in _update_column
    column_name, = self.column_name_re.match(column_def).groups()
AttributeError: 'NoneType' object has no attribute 'groups'

DB schema: (also happens with no primary key too)

CREATE TABLE [newTable]  (
  [test] TEXT NULL,
  [test1] TEXT NULL,
  PRIMARY KEY ([test])
)

As for the contents of the table, I just put gibberish for each of the rows in the test column, for the test1 column I set the first two rows to NULL and set the last row to gibberish.

coleifer commented 1 year ago

I cannot replicate.

Here is the table you provided

im-1693919717809

Dropping the test1 column

im-1693919727103

This is working fine and the column is dropped successfully:

im-1693919809081

LunarTwilight commented 1 year ago

Weird, now I can't reproduce it either. I can get an "internal server error" page if I try to drop the only row in a table tho.

[2023-09-06 05:07:02,478] ERROR in app: Exception on /test/drop-column/ [POST] 
    Traceback (most recent call last): 
      File "/usr/local/lib/python3.10/dist-packages/peewee.py", line 3197, in execute_sql 
        cursor.execute(sql, params or ()) 
    sqlite3.OperationalError: near ")": syntax error 

    During handling of the above exception, another exception occurred: 

    Traceback (most recent call last): 
      File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2525, in wsgi_app 
        response = self.full_dispatch_request() 
      File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1822, in full_dispatch_request 
        rv = self.handle_user_exception(e) 
      File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1820, in full_dispatch_request 
        rv = self.dispatch_request() 
      File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1796, in dispatch_request 
        return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) 
      File "/usr/local/lib/python3.10/dist-packages/sqlite_web/sqlite_web.py", line 248, in inner 
        return fn(table, *args, **kwargs) 
      File "/usr/local/lib/python3.10/dist-packages/sqlite_web/sqlite_web.py", line 347, in drop_column 
        migrate(migrator.drop_column(table, name)) 
      File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 886, in migrate 
        operation.run() 
      File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 164, in run 
        self._handle_result(method(*self.args, **kwargs)) 
      File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 155, in _handle_result 
        result.run() 
      File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 164, in run 
        self._handle_result(method(*self.args, **kwargs)) 
      File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 158, in _handle_result 
        self._handle_result(item) 
      File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 153, in _handle_result 
        self.execute(result) 
      File "/usr/local/lib/python3.10/dist-packages/playhouse/migrate.py", line 149, in execute 
        self.migrator.database.execute(node) 
      File "/usr/local/lib/python3.10/dist-packages/peewee.py", line 3210, in execute 
        return self.execute_sql(sql, params, commit=commit) 
      File "/usr/local/lib/python3.10/dist-packages/peewee.py", line 3194, in execute_sql 
        with __exception_wrapper__: 
      File "/usr/local/lib/python3.10/dist-packages/peewee.py", line 2970, in __exit__ 
        reraise(new_type, new_type(exc_value, *exc_args), traceback) 
      File "/usr/local/lib/python3.10/dist-packages/peewee.py", line 191, in reraise 
        raise value.with_traceback(tb) 
      File "/usr/local/lib/python3.10/dist-packages/peewee.py", line 3197, in execute_sql 
        cursor.execute(sql, params or ()) 
    peewee.OperationalError: near ")": syntax error