Git Product home page Git Product logo

gnatcoll-db's Introduction

The GNAT Components Collection (GNATcoll) - Database packages

This is the DB module of the GNAT Components Collection. Please refer to individual components for more details.

Dependencies

This module depends on the following external components, that should be available on your system:

  • GPRbuild
  • gnatcoll-core
  • As well as relevant third-party libraries required by components.

Configuring the build process

The following variables can be used to configure the build process:

General:

  • prefix: location of the installation, the default is the running GNAT installation root.

  • BUILD: control the build options: PROD (default) or DEBUG

  • PROCESSORS: parallel compilation (default is 0, which uses all available cores)

  • TARGET: for cross-compilation, auto-detected for native platforms

  • SOURCE_DIR: for out-of-tree build

  • INTEGRATED: treat prefix as compiler installation (yes/no) this is so that installed GNATcoll project can later be referenced as predefined project of this compiler; this adds a normalized target subdir to prefix default is "no"

Module-specific:

Please refer to individual components. To use the default options:

$ make setup

Building

The components of GNATcoll Database are built using standalone GPR project files, to build each of them is as simple as:

$ gprbuild gnatcoll-<component>.gpr

However, to build all versions of the library (static, relocatable and static-pic) it is simpler to use the provided Makefiles:

$ make -C <component>

Then, to install it:

$ make -C <component> install

Bug reports

Please send questions and bug reports to [email protected] following the same procedures used to submit reports with the GNAT toolset itself.

gnatcoll-db's People

Contributors

adadoom3 avatar adrienboulanger avatar anisimkov avatar anthonyleonardogracio avatar arnaudcharlet avatar asarhaddon avatar bobduff avatar briot avatar brosgol avatar enzbang avatar fabien-chouteau avatar fedor-rybin avatar godunko avatar julienbortolussiada avatar kanigsson avatar kokkonisd avatar lambourg avatar matteobordin avatar miranda-adacore avatar nikokrock avatar ogorodnik avatar pat-rogers avatar pmderodat avatar quentinochem avatar raph-amiard avatar reznikmm avatar setton avatar t-14 avatar turbogit avatar vcelier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gnatcoll-db's Issues

Constraint_Error in gnatcoll_db2ada (gnatcoll-sql-inspect.adb:190:18)

Hello! Trying to make first steps with ORM, and still cannot make code generator work. Updated everything, but nothing helps. Unhandled null access dereferencing happens.

Updated environment: Linux x86_64, GNAT 2017 GPL, XMLAda from Git, libgpr from Git, GNATCOLL from Git.

Schema.txt:
`| TABLE | Comm_Watch_Items | Comm_Watch_Item || Snapshots of known items |
| Comm_Watch_Item_Id | AUTOINCREMENT | PK || Auto-generated id |
| Id_On_Service | INTEGER | NOT NULL || Integer id as written in URLs and JSON |
| Id_Character_On_Service | CHARACTER(1) | NOT NULL || Character part of id as written in URLs |
| JSON_In_The_List | TEXT | NULL || JSON snapshot as appearing in the list |
| Date_In_The_List | TIMESTAMP | NULL || Time stamp of JSON snapshot as appearing in the list |
| JSON_Alone | TEXT | NULL || JSON snapshot if opened alone (usually more rich) |
| Date_Alone | TIMESTAMP | NULL || Time stamp of JSON snapshot if opened alone |
| UNIQUE: | Id_On_Service, Id_Character_On_Service | Full_Id_On_Service |

| TABLE | Comm_Watch_Bookmarks | Comm_Watch_Bookmark || Bookmark one-to-many relation (username-to-bookmark) |
| Comm_Watch_Bookmark_Id | AUTOINCREMENT | PK || Auto-generated id |
| Username | TEXT | NOT NULL || Username |
| Bookmark_Id_On_Service | INTEGER | NOT NULL || Integer bookmark id as written in URLs and JSON |
| Bookmark_Character_On_Service | CHARACTER(1) | NOT NULL || Character part of bookmark id as written in URLs |
| FK: | Comm_Watch_Items | Bookmark_Id_On_Service, Bookmark_Character_On_Service | Id_On_Service, Id_Character_On_Service |
| UNIQUE: | Username, Bookmark_Id_On_Service, Bookmark_Character_On_Service | Username_Bookmark |`

gnatcoll_db2ada -api Comm_Watch.Database -orm Comm_Watch.ORM -dbmodel Schema.txt

The problem disappears if I remove foreign key, but that destroys the whole point of ORM. I look at this line and cannot see anything wrong with it. All according to the documentation.

Generating Ada: supporting multiple Foreign Keys (4)

Even if the documentation contains information on the “FK:” lines for multiple foreign keys (implying tables with multiple PKs), both gnatcoll-sql-inspect.adb and dborm.py fails in some way in these cases.

In some obscure cases it seems that dborm.py assumes tables with just one PK. A comprehensive review is recommended. Or better, replace dborm.py by the proposed Ada module.

For example, dborm.py still complains on multiple Fks, cannot see the effect. In other cases there is a mismatch between parameters (see the generated code for functions of reverse relations in case of multiple Fks). In other cases, dborm.py changes second, etc. PK to the first PK (because it assumes it is the only one PK). It has been also detected that even it changes the data type of some FK.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

gnatcoll-db should include support for more “financial” types

Money is numeric(16,2) which is normally insufficient for financial applications (Money is intended for such applications, is it no?). Types T_Numeric_24_8 and T_Numeric_8_4 should be supported. For example, Forex (foreign currency market) is expressed with at least 6 decimals, many investment funds are also expressed with 6 decimals, etc.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

Generating Ada: updating views

Originally, SQL views were intended to be read-only combination of tables, however some DMBSs support updating views under limiting conditions (by automatically defining triggers to update the involved tables).

That is beyond gnatcoll_all2ada, therefore a new option must be defined for gnatcoll_all2ada: -updatable-views, for example, default false. In this case, no routines to update views shall be generated in the ORM code.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

Calling gnatcoll_all2ada with no “-omit-schema <the-sql-schema>”

Suppose that the database has a sql schema. If you try gnatcoll_all2ada with no “-omit-schema” then
lots of
tmp_orm:5047:14: error: child unit allowed only at library level
tmp_orm:5440:16: error: missing "is"
are issued by gnatchop.

However, if gnatcoll_all2ada is called with such option, all emitted SQL statements in your program will be rejected because the database sql schema is not in the search path of the database search path.

The solution is to insert in your program a SQL statement indicating the search path:
Execute (Connection => DB (Session),
Query => "set schema '';");

However that should be solved in the generated code, not in your program.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

gnatinspect database has some case sensitive columns

Some columns seemingly at random in the sql database generated by gnatinspect are case sensitive when by default they would not be. In particular name, language, path, fromEntity, toEntity, fromFile, toFile, and column are case sensitive in the database.

This makes analysing the database manually more difficult and should be an easy fix.

I don't know where xref/generated/gnatcoll-xref-database_names.ads is generated from, but it is clearly visible there that some names are surrounded in extra quotes NC_Path : aliased constant String := """path"""; while most are not NC_Stamp : aliased constant String := "stamp";.

gnatcoll_db2ada will quit with an obnoxious message, if python is not available

Trying to run gnatcoll_db2ada without python installed, even though python3 is available, will fail with the following message:

A database error occurred, please try again...
raised GNAT.EXPECT.INVALID_PROCESS : g-expect.adb:1133

This is an extremely unhelpful message. At the very least it should check if python3 command is available, as some systems are moving towards it but don't create a symlink for python for backwards compatibility.

gnatcoll_all2ada has enough information to generate better readable schema

For example:
gnatcoll_all2ada should have some parameters to generate:
• if there is a table or view description that starts by (), the 3rd column for tables should be automatically generated as
• if the name of the table or view ends in “s”, the 3rd column should be automatically generated using the name but removing the “s”. However, in some cases the result may not be corrected and should be modified by hand. Think in “currencies”.
• To control producing comments or not.
• To align columns. In addition, column alignment should be global to all tables.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

Generating Ada: supporting multiple Foreign Keys (3)

Even if the documentation contains information on the “FK:” lines for multiple foreign keys (implying tables with multiple PKs), both gnatcoll-sql-inspect.adb and dborm.py fails in some way in these cases.

dborm.py generates procedures for the reverse relation. In case of multiple Fks, there is a name conflict as the reverse relation name is the same for all Fks. The solution should be to postfix these routines with the individual FK name.

This solution has been implemented in the proposed replacement of dborm.py in the new Ada package.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

Error linking gnatinspect and gnatcoll_db2ada - recompile with -fPIC error message

I have been trying to compile the gnat collections/database and all has worked well so far except that I am having trouble linking the gnatinspect and gnatcoll_db2ada modules. I have used my own prefix but the other options for 'make setup' are the defaults. I have installed gnat 11.3 from Debian/testing.

The error message for gnatinspect is:

gprbuild -p -m --target=x86_64-linux-gnu  -j2 -XLIBRARY_TYPE=static -XXMLADA_BUILD=static -XGPR_BUILD=static -XGNATCOLL_VERSION=0.0 -XBUILD=PROD  gnatinspect.gpr
Setup
   [mkdir]        object directory for project Gnatinspect
Compile
   [Ada]          gnatinspect.adb
Bind
   [gprbind]      gnatinspect.bexch
   [Ada]          gnatinspect.ali
Link
   [link]         gnatinspect.adb
/usr/bin/ld: /opt/ides/gnat/gnat-collections/lib/gnatcoll_sql.static/libgnatcoll_sql.a(gnatcoll-sql-exec.o): warning: relocation against `gnatcoll__sql__exec__database_engines__iteratorFD' in read-only section `.text'
/usr/bin/ld: gnatinspect.o: relocation R_X86_64_PC32 against symbol `system__soft_links__abort_defer' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
gprbuild: link of gnatinspect.adb failed
gprbuild: failed command was: /usr/bin/gcc-11 gnatinspect.o b__gnatinspect.o /opt/ides/gnat/gnat-collections/lib/gnatcoll_xref.static/libgnatcoll_xref.a /opt/ides/gnat/gnat-collections/lib/gnatcoll_iconv.static/libgnatcoll_iconv.a /opt/ides/gnat/gnat-collections/lib/gnatcoll_sqlite.static/libgnatcoll_sqlite.a /opt/ides/gnat/gnat-collections/lib/gnatcoll_sql.static/libgnatcoll_sql.a /opt/ides/gnat/gnat-collections/lib/gnatcoll.static/libgnatcoll.a /opt/ides/gnat/gprbuild/lib/gpr/static/gpr/libgpr.a -L/usr/lib/x86_64-linux-gnu/ -lxmlada_schema -lxmlada_dom -lxmlada_sax -lxmlada_input -lxmlada_unicode -lpthread -L/home/xxxxx/Programs/Development-Tools/GNAT/gnat-collections/db/gnatinspect/obj/ -L/home/xxxxx/Programs/Development-Tools/GNAT/gnat-collections/db/gnatinspect/obj/ -L/opt/ides/gnat/gnat-collections/lib/gnatcoll.static/ -L/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_unicode/ -L/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_input/ -L/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_sax/ -L/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_dom/ -L/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_schema/ -L/opt/ides/gnat/gprbuild/lib/gpr/static/gpr/ -L/opt/ides/gnat/gnat-collections/lib/gnatcoll_xref.static/ -L/opt/ides/gnat/gnat-collections/lib/gnatcoll_sqlite.static/ -L/opt/ides/gnat/gnat-collections/lib/gnatcoll_sql.static/ -L/opt/ides/gnat/gnat-collections/lib/gnatcoll_iconv.static/ -L/usr/lib/gcc/x86_64-linux-gnu/11/adalib/ -shared -lgnarl-11 -lgnat-11 -lutil -lrt -lpthread -ldl -Wl,-rpath-link,/usr/lib/gcc/x86_64-linux-gnu/11//adalib -Wl,-z,origin,-rpath,/usr/lib/x86_64-linux-gnu:$ORIGIN/:/opt/ides/gnat/gnat-collections/lib/gnatcoll.static:/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_unicode:/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_input:/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_sax:/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_dom:/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_schema:/opt/ides/gnat/gprbuild/lib/gpr/static/gpr:/opt/ides/gnat/gnat-collections/lib/gnatcoll_xref.static:/opt/ides/gnat/gnat-collections/lib/gnatcoll_sqlite.static:/opt/ides/gnat/gnat-collections/lib/gnatcoll_sql.static:/opt/ides/gnat/gnat-collections/lib/gnatcoll_iconv.static:/usr/lib/gcc/x86_64-linux-gnu/11/adalib:/usr/lib64:/usr/lib -o gnatinspect
make: *** [Makefile:104: build] Error 4

and the error message for gnatcoll_db2ada is much the same, and is as follows:

gprbuild -p -m --target=x86_64-linux-gnu  -j2 -XLIBRARY_TYPE=static -XXMLADA_BUILD=static -XGPR_BUILD=static -XGNATCOLL_VERSION=0.0 -XBUILD=PROD  gnatcoll_db2ada.gpr
Setup
   [mkdir]        object directory for project GNATCOLL_DB2Ada
Compile
   [Ada]          gnatcoll_db2ada.adb
   [Ada]          gnatcoll-db2ada.ads
   [Ada]          gnatcoll-db2ada-main.adb
Bind
   [gprbind]      gnatcoll_db2ada.bexch
   [Ada]          gnatcoll_db2ada.ali
Link
   [link]         gnatcoll_db2ada.adb
/usr/bin/ld: /opt/ides/gnat/gnat-collections/lib/gnatcoll_sql.static/libgnatcoll_sql.a(gnatcoll-sql_impl.o): warning: relocation against `gnatcoll__sql_impl__sql_parameter_characterB3692s' in read-only section `.text'
/usr/bin/ld: /home/brett/Programs/Development-Tools/GNAT/gnat-collections/db/gnatcoll_db2ada/obj/gnatcoll-db2ada-main.o: relocation R_X86_64_PC32 against symbol `system__soft_links__abort_defer' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
gprbuild: link of gnatcoll_db2ada.adb failed
gprbuild: failed command was: /usr/bin/gcc-11 gnatcoll_db2ada.o b__gnatcoll_db2ada.o /home/xxxxx/Programs/Development-Tools/GNAT/gnat-collections/db/gnatcoll_db2ada/obj/gnatcoll-db2ada.o /home/xxxxx/Programs/Development-Tools/GNAT/gnat-collections/db/gnatcoll_db2ada/obj/gnatcoll-db2ada-main.o /opt/ides/gnat/gnat-collections/lib/gnatcoll_sql.static/libgnatcoll_sql.a /opt/ides/gnat/gnat-collections/lib/gnatcoll.static/libgnatcoll.a /opt/ides/gnat/gprbuild/lib/gpr/static/gpr/libgpr.a -L/usr/lib/x86_64-linux-gnu/ -lxmlada_schema -lxmlada_dom -lxmlada_sax -lxmlada_input -lxmlada_unicode -L/home/xxxxx/Programs/Development-Tools/GNAT/gnat-collections/db/gnatcoll_db2ada/obj/ -L/home/xxxxx/Programs/Development-Tools/GNAT/gnat-collections/db/gnatcoll_db2ada/obj/ -L/opt/ides/gnat/gnat-collections/lib/gnatcoll.static/ -L/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_unicode/ -L/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_input/ -L/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_sax/ -L/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_dom/ -L/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_schema/ -L/opt/ides/gnat/gprbuild/lib/gpr/static/gpr/ -L/opt/ides/gnat/gnat-collections/lib/gnatcoll_sql.static/ -L/usr/lib/gcc/x86_64-linux-gnu/11/adalib/ -shared -lgnarl-11 -lgnat-11 -lrt -lpthread -ldl -Wl,-rpath-link,/usr/lib/gcc/x86_64-linux-gnu/11//adalib -Wl,-z,origin,-rpath,/usr/lib/x86_64-linux-gnu:$ORIGIN/:/opt/ides/gnat/gnat-collections/lib/gnatcoll.static:/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_unicode:/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_input:/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_sax:/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_dom:/usr/lib/x86_64-linux-gnu/ada/adalib/xmlada_schema:/opt/ides/gnat/gprbuild/lib/gpr/static/gpr:/opt/ides/gnat/gnat-collections/lib/gnatcoll_sql.static:/usr/lib/gcc/x86_64-linux-gnu/11/adalib:/usr/lib64:/usr/lib -o gnatcoll_db2ada
make: *** [Makefile:107: build] Error 4

I have successfully built gnatcoll/sql and so am puzzled as to what I have done wrong.

Stack overflow when building the relocatable libraries

Once built and installed the sql subproject (with relocatable, static-pic and static libraries), it is the turn of postgres and sqlite. But in these cases the binder raises the following message:

   Build Libraries
      [gprlib]       gnatcoll_postgres.lexch
      [bind SAL]     gnatcoll_postgres
   
   raised STORAGE_ERROR : stack overflow or erroneous memory access
gprlib: invocation of /opt/GNAT/2021/bin/gnatbind failed
gprbuild: could not build library for project gnatcoll_postgres
make: *** [Makefile:123: build-relocatable] Error 4

Modifying to an exaggerated degree the process stack size produces the same result.
The only way to proceed is to forget relocatable/static-pic libraries and have only the static one.
So change the makefile.setup to ENABLE_SHARED=no.

The environment was Linux Xubuntu 22.04, GNAT Community 2021 and Postgresql 13.6.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

Generating Ada: supporting multiple Foreign Keys (1)

Even if the documentation contains information on the “FK:” lines for multiple foreign keys (implying tables with multiple PKs), both gnatcoll-sql-inspect.adb and dborm.py fails in some way in these cases.

gnatcoll-sql-inspect.adb reads from the SQL database and correctly builds the internal schema. But the final step is to check orphan Fks. This last test fails because the function Get_PK for a table with multiple Pks returns No_Fields.

The solution is to purge such orphan FKDs.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

Generating Ada: Autoincrement Fields for sqlite

Autoincrement fields in sqlite are implemented as 64-bit signed integer (see https://www.sqlite.org/autoinc.html) and automatically are primary keys (different from Postgresql where autoincrement fields are not automatically primary key).

They are mapped in the schema to Integer Autoincrement Primary Key (see gnatcoll-sql-sqlite-builder.adb around line 1155), which is correct.

However they are mapped later to Ada Integer instead of Ada Long_Long_Integer. Also in gantcoll-sql-inspec.ads, this has to be changed having its Field_Mapping changed to SQL_Field_Bigint.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

Autoincrement Fields for Postgresql

Autoincrement fields (in Postgresql terminology smallserial, serial or bigserial) are mapped in the schema correctly to smallint, integer and bigint. If some of these fields is primary key, it is also correctly marked.

But when extracting the information from the Postgresql database, the autoincrement property is not marked at all in the generated schema.

This situation must be corrected, for example by including a new field property (named Serial) and then set it depending upon the information returned by Postgresql. Obviously the function “is_autoincrement” has to be modified. The python module dborm.py has to be modified too, admitting now in the third column the key “PK,SERIAL” for smallint, integer and bigint.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

Cannot make 'sql' component of database collections due to UTC_Time_Offset not visible.

I have compiled these components in the past, but today when I tried (have not done it for a while - so did a fetch from git), it fails when I try to build the 'sql' component, which then as this is needed for some of the other components, causes them to fail as well. I have performed a 'make -C sql clean' and then a 'make -C sql setup' before the 'make -C sql'. The make command produces the following error message:

gprbuild -p -m --target=x86_64-linux  -j2 -XGNATCOLL_VERSION=0.0 -XBUILD=PROD  -XLIBRARY_TYPE=static -XXMLADA_BUILD=static -XGPR_BUILD=static \
	gnatcoll_sql.gpr
Compile
   [Ada]          gnatcoll-sql_impl.adb
   [Ada]          gnatcoll-sql-sessions.adb
gnatcoll-sql_impl.adb:1679:44: "UTC_Time_Offset" is not visible (more references follow)
gnatcoll-sql_impl.adb:1679:44: non-visible declaration at a-catizo.ads:28
gnatcoll-sql_impl.adb:1679:44: non-visible declaration at a-calend.ads:403

   compilation of gnatcoll-sql_impl.adb failed

gprbuild: *** compilation phase failed
make: *** [Makefile:116: build-static] Error 4

I am using GNAT 2020 but have also built the git version of gprbuild. Using this produces the same failure. I am presuming that my setup is at fault and would appreciate any help that people are willing to provide.

Postgresql: Null_Parameter not working for prepared querys

Passing a Null_Paramter to a prepared statment causes a syntax error in postgresql with anything but textfields.
In the function GNATCOLL.SQL.Postgres.Gnade.Exec_Prepared any Null_Parameter is passed to PQexecPrepared as a string and consequntly gets quoted before being send to the db.
Quick fix i tested:
pass Interfaces.C.Strings.Null_Ptr to PQexecPrepared instead.
Example:
if Params (Integer (P) + Params'First) = Null_Parameter then
Vals (P) := Interfaces.C.Strings.Null_Ptr;
else
Vals (P) := CS.New_String(Params (Integer (P) + Params'First).Image (Format));
end if;
gnatcoll-sql-postgres-gnade.adb.txt

Generating Ada: routine “from_cache”

dborm.py generates a routine “from_cache” only for tables with just one PK and integer. This situation must be modified to contemplate the case of just one PK but now smallint, integer, bigint.

Note that gnatcoll-sql-sessions is also affected, in particular the cache part. Even sqlite autoincrement are PKs but with 64 bits, so the actual implementation has this error: change Integer to Long_Long_Integer.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

PGRES_FATAL_ERROR ERROR: invalid name syntax in ORM SELECT currval

I am getting this trace when trying to insert new data via ORM:

[SQL.ERROR] select failed: SELECT currval('"Comm_Watch_Items"_"Comm_Watch_Item_Id"_seq') PGRES_FATAL_ERROR ERROR: invalid name syntax

Environment: Linux x86_64, GNAT 2017 GPL, XMLAda from Git, libgpr from Git, GNATCOLL from Git (Change-Id: Ia6649032bde129c9ed36e359f2a75ffc2530586a).

Generating the schema: Database field order is not honored in the generated schema

Given that fields are alphabetically classified by gnatcoll_all2ada.

We must assume that the order of fields in the Database is defined by the Database Designer and such order must not be changed.

It is in gnatcoll-sql-postgres-builder.adb procedure For_Each_Field having the clause “ ORDER BY pg_attribute.attname”. Please comment it out.

For more explanations, you can read the report
https://github.com/fdesp87/gnatcoll-db/examples/mytests/Report.odt

Generating Ada: Missing procedure to define a primary key

Note that not all primary keys are autoincrement, so for tables with primary keys that are not autoincrement, there is not way to define a new row, as it is nor possible to assign a value to the primary key field.

The solution is that the functions New_ include parameters for the primary key fields. That implies modifications to dborm.py, which is in python, a surprise as this is Ada generating Ada. In the indicated github path an full Ada solution is included, replacing the python module.

The documentation is also misleading. It is indicated that it is highly recommended to set a primary key on all tables, also recommending using integers for such primary keys for efficiency reasons (i. e. autoincrement). This is not an accurate description: it must say that tables having non-autoincrement primary keys cannot be expanded (using gnatcoll-db) with new rows as the generated Ada code do not include routines to define new rows in these cases.

Gnatinspect fails to generate the database data

I have a source code file which contains UTF-8 characters, i.e.: type ℕ is range 1..2**16-1. I normally compile it with the -gnatW8 switch and it works flawlessly, but gnatinspect(1) doesn't generate entities at all.

Pull requests temporarily on hold

Dear contributors,

Following the switch to modular organization, we are working on the testsuite refactoring. Before the testsuite is in place we can't accept pull requests.

We apologize in advance, and thank you for your patience!

Documentation doesn't mention requirement for table names to be lower case for ORM to work

Due to the nature of the dborm code, all table names in a model file must be lower-case, otherwise a KeyError will be generated at line 2257 in dborm.py.

Can be reproduced (at least for me) using:

| TABLE | Alpha   | A        || Table A
| id    | INTEGER | PK       || Auto-generated id (aliases rowid)
| data  | TEXT    | NOT NULL || The actual text of table A

| TABLE | Beta       | B        || Table B
| id    | INTEGER    | PK       || Auto-generated id (aliases rowid)
| data  | FK Alpha() | NOT NULL || Just a reference to A

And gnatcoll_db2ada -dbmodel <file_above> -orm ORM.

Which produces a python traceback. Switching the table names to lower case fixes this.

Therefore either the documentation should be updated to reflect this (I'm reading from https://docs.adacore.com/gnatcoll-docs/sql.html where the only description is "name" is the name of the table) or the code should be updated to allow different casings (even just applying a to_lower at the given line should work, though I haven't read enough of the code to verify).

Notes:

I don't have access to the most recent version of gnatcoll, so this could have already been fixed, but the python file in question hasn't changed between these versions and the result can be obtained by directly calling the dborm python script with the appropriate arguments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.