Mercurial > p > roundup > code
annotate scripts/schema_diagram.py @ 6593:e70e2789bc2c
issue2551189 - increase text search maxlength
This removes I think all the magic references to 25 and 30 (varchar
size) and replaces them with references to maxlength or maxlength+5.
I am not sure why the db column is 5 characters larger than the size
of what should be the max size of a word, but I'll keep the buffer
of 5 as making it 1/5 the size of maxlength makes less sense.
Also added tests for fts search in templating which were missing.
Added postgres, mysql and sqlite native indexing backends in which to
test fts. Added fts test to native-fts as well to make sure it's
working.
I want to commit this now for CI.
Todo:
add test cases for the use of FTS in the csv output in
actions.py. There is no test coverage of the match case there.
change maxlength to a higher value (50) as requested in the ticket.
Modify existing extremewords test cases to allow words > 25 and < 51
write code to migrate column sizes for mysql and postgresql to match
maxlength I will roll this into the version 7 schema update that
supports use of database fts support.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 25 Jan 2022 13:22:00 -0500 |
| parents | 23b8e6067f7c |
| children | 9c3ec0a5c7fc |
| rev | line source |
|---|---|
| 1166 | 1 #! /usr/bin/python |
| 2 # | |
| 3 # Schema diagram generator contributed by Stefan Seefeld of the fresco | |
| 4 # project http://www.fresco.org/. | |
| 5 # | |
| 6 # It generates a 'dot file' that is then fed into the 'dot' | |
| 7 # tool (http://www.graphviz.org) to generate a graph: | |
| 8 # | |
| 9 # %> ./schema.py | |
| 10 # %> dot -Tps schema.dot -o schema.ps | |
| 11 # %> gv schema.ps | |
| 12 # | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
13 from __future__ import print_function |
| 1166 | 14 import sys |
| 15 import roundup.instance | |
| 16 | |
| 17 # open the instance | |
| 18 instance = roundup.instance.open(sys.argv[1]) | |
| 19 db = instance.open() | |
| 20 | |
| 21 # diagram preamble | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
22 print('digraph schema {') |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
23 print('size="8,6"') |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
24 print('node [shape="record" bgcolor="#ffe4c4" style=filled]') |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
25 print('edge [taillabel="1" headlabel="1" dir=back arrowtail=ediamond]') |
| 1166 | 26 |
| 27 # get all the classes | |
|
5395
23b8e6067f7c
Python 3 preparation: update calls to dict methods.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5376
diff
changeset
|
28 types = list(db.classes.keys()) |
| 1166 | 29 |
| 30 # one record node per class | |
| 31 for i in range(len(types)): | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
32 print('node%d [label=\"{%s|}"]'%(i, types[i])) |
| 1166 | 33 |
| 34 # now draw in the relations | |
| 35 for name in db.classes.keys(): | |
| 36 type = db.classes[name] | |
| 37 attributes = type.getprops() | |
| 38 for a in attributes.keys(): | |
| 39 attribute = attributes[a] | |
| 40 if isinstance(attribute, roundup.hyperdb.Link): | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
41 print('node%d -> node%d [label=%s]'%(types.index(name), |
| 1166 | 42 types.index(attribute.classname), |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
43 a)) |
| 1166 | 44 elif isinstance(attribute, roundup.hyperdb.Multilink): |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
45 print('node%d -> node%d [taillabel="*" label=%s]'%(types.index(name), |
| 1166 | 46 types.index(attribute.classname), |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
47 a)) |
| 1166 | 48 # all done |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
49 print('}') |
