Opened 6 months ago

Closed 6 months ago

Last modified 5 months ago

#26702 closed enhancement (fixed)

Py3: Fix database/sql_db module for python3

Reported by: vklein Owned by:
Priority: major Milestone: sage-8.5
Component: python3 Keywords:
Cc: Merged in:
Authors: Vincent Klein Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 4b2436c (Commits) Commit:
Dependencies: Stopgaps:

Description (last modified by vklein)

In sql_db.py method show use a select * which give the column list with default order.
The default order being defined by the CREATE TABLE sql statement.

Given that the table_skeleton use a dict, we cannot predict the order of columns in the table (Because of that using add_rows without defining entry_order parameter is tricky).

In this ticket i fixed the doctests using an OrderedDict? instead of dict.

Change History (10)

comment:1 Changed 6 months ago by vklein

  • Description modified (diff)

comment:2 Changed 6 months ago by vklein

  • Description modified (diff)

comment:3 Changed 6 months ago by vklein

  • Summary changed from Py3: Fix database module for python3 to Py3: Fix database/sql_db module for python3

comment:4 Changed 6 months ago by vklein

  • Description modified (diff)

comment:5 Changed 6 months ago by vklein

  • Branch set to u/vklein/py3__fix_database_sql_db_module_for_python3

comment:6 Changed 6 months ago by vklein

  • Commit set to 4b2436cb0a80de412bbb6391c17ea27d1e367215
  • Status changed from new to needs_review

New commits:

4b2436cTrac #26702: Fix database/sql_db module for python3

comment:7 Changed 6 months ago by chapoton

  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review

ok, looks good

comment:8 Changed 6 months ago by vklein

Merci !

comment:9 Changed 6 months ago by vbraun

  • Branch changed from u/vklein/py3__fix_database_sql_db_module_for_python3 to 4b2436cb0a80de412bbb6391c17ea27d1e367215
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:10 Changed 5 months ago by vdelecroix

  • Commit 4b2436cb0a80de412bbb6391c17ea27d1e367215 deleted

Could this ticket be the cause of

sage -t --long src/sage/databases/sql_db.py
**********************************************************************
File "src/sage/databases/sql_db.py", line 956, in sage.databases.sql_db.SQLDatabase.__init__
Failed example:
    D.show('simon')
Expected:
    graph6               vertices             edges
    ------------------------------------------------------------
    ?                    0                    0
    @                    1                    0
    A?                   2                    0
    A_                   2                    1
    B?                   3                    0
    BG                   3                    1
    BW                   3                    2
    Bw                   3                    3
    C?                   4                    0
    C@                   4                    1
    CB                   4                    2
    CF                   4                    3
    CJ                   4                    3
    CK                   4                    2
    CL                   4                    3
    CN                   4                    4
    C]                   4                    4
    C^                   4                    5
    C~                   4                    6
Got:
    graph6               vertices             edges               
    ------------------------------------------------------------
    ?                    0                    0                   
    @                    1                    0                   
    A?                   2                    0                   
    A_                   2                    1                   
    B?                   3                    0                   
    BG                   3                    1                   
    BW                   3                    2                   
    Bw                   3                    3                   
    C?                   4                    0                   
    C@                   4                    1                   
    CB                   4                    2                   
    CF                   4                    3                   
    CJ                   4                    3                   
    C`                   4                    2                   
    CR                   4                    3                   
    CN                   4                    4                   
    Cr                   4                    4                   
    C^                   4                    5                   
    C~                   4                    6                   
**********************************************************************
File "src/sage/databases/sql_db.py", line 1004, in sage.databases.sql_db.SQLDatabase.__init__
Failed example:
    E.show('simon')
Expected:
    graph6               vertices             edges
    ------------------------------------------------------------
    ?                    0                    0
    @                    1                    0
    A?                   2                    0
    A_                   2                    1
    B?                   3                    0
    BG                   3                    1
    BW                   3                    2
    Bw                   3                    3
    C?                   4                    0
    C@                   4                    1
    CB                   4                    2
    CF                   4                    3
    CJ                   4                    3
    CK                   4                    2
    CL                   4                    3
    CN                   4                    4
    C]                   4                    4
    C^                   4                    5
    C~                   4                    6
Got:
    graph6               vertices             edges               
    ------------------------------------------------------------
    ?                    0                    0                   
    @                    1                    0                   
    A?                   2                    0                   
    A_                   2                    1                   
    B?                   3                    0                   
    BG                   3                    1                   
    BW                   3                    2                   
    Bw                   3                    3                   
    C?                   4                    0                   
    C@                   4                    1                   
    CB                   4                    2                   
    CF                   4                    3                   
    CJ                   4                    3                   
    C`                   4                    2                   
    CR                   4                    3                   
    CN                   4                    4                   
    Cr                   4                    4                   
    C^                   4                    5                   
    C~                   4                    6                   
**********************************************************************
1 item had failures:
   2 of  26 in sage.databases.sql_db.SQLDatabase.__init__
    [288 tests, 2 failures, 1.59 s]

Discussion on sage-devel here.

Note: See TracTickets for help on using tickets.