louking / rrwebapp

Race Results Web Application
0 stars 1 forks source link

divisions, series views: Copy from Year doesn't seem to work across club boundaries #598

Open louking opened 1 year ago

louking commented 1 year ago
Exception on /admin/_copyseries [POST]

Traceback (most recent call last):
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py)", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/default.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/default.py)", line 732, in do_execute
    cursor.execute(statement, parameters)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/cursors.py](http://scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/cursors.py)", line 206, in execute
    res = self._query(query)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/cursors.py](http://scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/cursors.py)", line 319, in _query
    db.query(q)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/connections.py](http://scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/connections.py)", line 254, in query
    _mysql.connection.query(self, query)
MySQLdb.IntegrityError: (1062, "Duplicate entry 'grandprix-2023-2' for key 'name'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/flask/app.py](http://scoretility.com/venv/lib/python3.9/site-packages/flask/app.py)", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/flask/app.py](http://scoretility.com/venv/lib/python3.9/site-packages/flask/app.py)", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/flask/app.py](http://scoretility.com/venv/lib/python3.9/site-packages/flask/app.py)", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/flask/app.py](http://scoretility.com/venv/lib/python3.9/site-packages/flask/app.py)", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/flask/views.py](http://scoretility.com/venv/lib/python3.9/site-packages/flask/views.py)", line 107, in view
    return current_app.ensure_sync(self.dispatch_request)(**kwargs)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/flask/views.py](http://scoretility.com/venv/lib/python3.9/site-packages/flask/views.py)", line 188, in dispatch_request
    return current_app.ensure_sync(meth)(**kwargs)
  File "/var/www/[scoretility.com/rrwebapp/rrwebapp/views/admin/race.py](http://scoretility.com/rrwebapp/rrwebapp/views/admin/race.py)", line 603, in post
    insert_or_update(db.session,Series,newseries,name=[newseries.name](http://newseries.name/),year=thisyear,club_id=club_id,skipcolumns=['id'])
  File "/var/www/[scoretility.com/rrwebapp/rrwebapp/model.py](http://scoretility.com/rrwebapp/rrwebapp/model.py)", line 136, in insert_or_update
    session.flush()
  File "<string>", line 2, in flush
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py)", line 3383, in flush
    self._flush(objects)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py)", line 3523, in _flush
    transaction.rollback(_capture_exception=True)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py)", line 70, in __exit__
    compat.raise_(
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/util/compat.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/util/compat.py)", line 208, in raise_
    raise exception
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py)", line 3483, in _flush
    flush_context.execute()
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/unitofwork.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/unitofwork.py)", line 456, in execute
    rec.execute(self)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/unitofwork.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/unitofwork.py)", line 630, in execute
    util.preloaded.orm_persistence.save_obj(
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/persistence.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/persistence.py)", line 245, in save_obj
    _emit_insert_statements(
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/persistence.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/orm/persistence.py)", line 1238, in _emit_insert_statements
    result = connection._execute_20(
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py)", line 1705, in _execute_20
    return meth(self, args_10style, kwargs_10style, execution_options)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/sql/elements.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/sql/elements.py)", line 333, in _execute_on_connection
    return connection._execute_clauseelement(
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py)", line 1572, in _execute_clauseelement
    ret = self._execute_context(
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py)", line 1943, in _execute_context
    self._handle_dbapi_exception(
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py)", line 2124, in _handle_dbapi_exception
    util.raise_(
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/util/compat.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/util/compat.py)", line 208, in raise_
    raise exception
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py)", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/default.py](http://scoretility.com/venv/lib/python3.9/site-packages/sqlalchemy/engine/default.py)", line 732, in do_execute
    cursor.execute(statement, parameters)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/cursors.py](http://scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/cursors.py)", line 206, in execute
    res = self._query(query)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/cursors.py](http://scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/cursors.py)", line 319, in _query
    db.query(q)
  File "/var/www/[scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/connections.py](http://scoretility.com/venv/lib/python3.9/site-packages/MySQLdb/connections.py)", line 254, in query
    _mysql.connection.query(self, query)
sqlalchemy.exc.IntegrityError: (MySQLdb.IntegrityError) (1062, "Duplicate entry 'grandprix-2023-2' for key 'name'")
[SQL: INSERT INTO series (club_id, name, year, membersonly, calcoverall, calcdivisions, calcagegrade, orderby, hightolow, allowties, averagetie, options, maxraces, multiplier, maxgenpoints, maxdivpoints, maxbynumrunners, active, description, oaawards, divawards, minraces, tieoptions) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)]
[parameters: (2, 'grandprix', 2023, 1, 1, 1, 0, 'overallplace', 0, None, 0, None, 5, 1, 50, 10, 0, 1, None, 5, 5, 4, 'head_to_head_points, average_points, div_compare_overall')]
(Background on this error at: https://sqlalche.me/e/14/gkpj)