Commit Graph

35 Commits

Author SHA1 Message Date
anisimko
9dadb68f7d GNATCOLL.SQL example
U108-018

Change-Id: Ic2be45cd8fa8457416129c1d0f09720d01a49a97
2021-01-10 16:40:35 +06:00
Vasiliy Fofanov
ce99ac280e Initial version of gnatcoll-db module.
Part of major reorganization of gnatcoll for better modularity and
maintainability.

Change-Id: Iad961b53634520081eb90c37aff2bfdbf58b2e06
TN: P909-033 no-precommit-check
2017-10-29 15:30:27 +01:00
Dmitriy Anisimkov
10572a9f0c Revert "Merge feature Deepbluecapital contribs sql"
This reverts commit ddc7448693566d8433a8ff04e4b3cb5beac3451f, reversing
changes made to e9a7649d7abe47f6bdaa88a97871842692152ec1.

Change-Id: I2fb1cd4e5f67eeef6e7402b4f61af0a0cdf1ebf5
2017-09-14 16:19:55 +02:00
Emmanuel Briot
e2b9f58321 Improvements to GNATCOLL.SQL
This commit aggregates multiple smaller commits, and provides the
 following major reorganization to GNATCOLL.SQL*

(gnatcoll_db2ada):
 report an error when the user used a wrong keyword
 In a database schema description, tables should start with TABLE,
 ABSTRACT TABLE or VIEW. Report an error in other cases

(database description files):
 Add support for different type name in schema description and SQL.
 In some cases, users might want to use a different name in the schema
 description files than actually used by SQL.

Custom field types
 A single generic package instantiation is needed to create custom field
 types. This is also used for all predefined field types.
 This avoids duplication of information between the three or four
 instantiations we had to do before, and ensures better consistency. For
 instance, a SQL_Field_Float was sometimes mapped to "float" and
 sometimes to "real". Likewise, a time field was sometimes a "timestamp"
 and sometimes a "timestamp with time zone".
 This also ensures that users do not forget to register their custom
 types, or to make them available to database description files and
 gnatcoll_db2ada.

fix mapping of "numeric"
 "numeric" should be mapped to a float, but "numeric(precision)" should
 be an integer (It has a scale of 0), as well as "numeric(precision,0)".
 And "numeric(position,scale)" with a scale other than 0 should be a
 float.
 Map a sql "numeric(precision,scale)" to Ada Long_Long_Float.
 A Float is not enough to represent the full precision.
 Fix duplicate type definition in GNATCOLL (SQL_Field_Long_Float).
 In particular, one of the definitions was mapping a "float" in a
 database description file to an Ada "Float", though the documentation
 in gnatcoll-sql.ads says these were mapped to Long_Long_Float.

(Long_Float_Value): renamed to Long_Long_Float_Value for consistency.
 In fact, long float fields are implemented as Long_Long_Float, so we
 had an inconsistency which is now easier to detect with the new
 organization of generic packages.

(Cast): function moved to the generic Field_Types
 It is now easier for people writing custom sql types to have access to
 "CAST (field AS type)" functions

Simplify handling of parameter types
 (Field_Mapping): no longer needs to know about parameter types, just the
  SQL name is enough. This simplifies instantions of
  Simple_Field_Mapping, makes things more efficient, and will make it
  possible to move this type directly in the Field_Types package, to ease
  creating new custom types.
 (SQL_Parameter_Type): remove the Type_String primitive operation, not
  needed since we never override it anyway. Minor efficiency gain.
  Use XString is more place, instead of String_Access, also for efficiency
  since most of the time the strings are small. So we are saving on
  mallocs.

Ranges
 We need to retrieve a type with static bounds which can be manipulated
 from Ada. Previously we were retrieving a SQL type, whose bounds could
 be defined as SQL functions.
 (Ada_Range): is now a pure Ada type (unrelated to SQL) which can be
  used to perform interval operations. At some point, it might make
  sense to make it into a top-level GNATCOLL package.

Dates
 When we create a date with Ada.Calendar.Time_Of (with no seconds),
 then depending on the timezone it is possible that the resulting
 string was set to the day before.
 For instance, the sql/ranges test was using an Ada Time 2017-12-31,
 but the string '2017-12-30' was passed to postgres when run from
 Paris timezone in the morning.

Change how we override default getters for cursors. A DBMS_Cursor used
 to have primitives to convert the return value (usually a string) to
 a more specific Ada type. But in fact, we need those functions at the
 level of the formatter (postgresql or sqlite) so that we can parse a
 range value's bounds.

Testsuite
 Skip tests that require running postgresql, when the current
 environment does not provide this.
2017-08-29 12:51:57 +02:00
Nicolas Setton
975c9d590b Remove support for GtkAda, Pygtk, PyGObject
This cleans up the dependency tree. The corresponding code
still exists and has been moved to the GPS repository, which
is probably the only place where this is needed.

For Q727-014

Change-Id: I2c9df154694fb3f1dcdc62c50be68d332a967f59
2017-07-31 11:35:39 -04:00
Emmanuel Briot
a40e8eca06 Update copyright notices
Q102-020

Change-Id: Ib1e3678311d32aa120fc36f2557654e5cab2f370
2017-01-03 10:05:49 +01:00
Emmanuel Briot
0b65ec38ff Fix build error in examples
From P120-046

Change-Id: I4392d6161517c21ed875da02adde2db9adc834b4
2016-01-21 16:38:49 +01:00
Emmanuel Briot
45b533f152 Update copyright year
Change-Id: Ibc7640eaef7ae555da7e11b179d5b153ec98e4ea
2016-01-04 12:03:03 +01:00
Emmanuel Briot
2a4a1c25e3 Remove -gnat05 from test and examples project files
GNATCOLL has been compiled with the default compiler mode (Ada2012)
for a while now, so we should do the same for the testsuite.

Rename some "pragma Ada_12" to "pragma Ada_2012" for consistency

OC08-006

Change-Id: Ia63d2cfcde2caa7c85fb67e346fbc3177e74724b
2015-12-08 12:49:41 +01:00
Dmitriy Anisimkov
1f0bb94840 Fix task unsafe types SQL_Table_List and SQL_Left_Join_Table.
OC08-003

Remove -gnat05 from testsuite gpr files to avoid compilation errors.

Change-Id: I908efdcda12c93a4ad170bbbdef29be4ed2ebc67
2015-12-08 13:40:02 +06:00
Pascal Obry
d28e41c343 Rework installation step using gprinstall.
This made it possible to clean-up lot of code.

For L626-014.

Change-Id: I0fea4a395a815858e4ebf2ec15a4af57864c9615
2015-06-08 11:01:14 +02:00
Emmanuel Briot
a250d56e38 Update copyright notices to 2015 2015-01-05 11:16:11 +01:00
Emmanuel Briot
e558d2f189 Make sure the example compiles with recent versions of GtkAda.
N618-047

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@229232 936e1b1b-40f2-da11-902a-00137254ae57
2014-06-19 07:16:32 +00:00
Emmanuel Briot
06ffa46530 Update copyright notices to 2014
N103-019

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@221487 936e1b1b-40f2-da11-902a-00137254ae57
2014-01-06 10:29:22 +00:00
Emmanuel Briot
9b9bca3327 Update copyright notice to 2013
M103-015

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@200402 936e1b1b-40f2-da11-902a-00137254ae57
2013-01-08 10:50:34 +00:00
Emmanuel Briot
763f2eaf3e Make sure the examples can be compiled with a simple "make"
git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@193912 936e1b1b-40f2-da11-902a-00137254ae57
2012-09-03 09:29:26 +00:00
Emmanuel Briot
c0a6d53182 Fix compilation error in the examples
L725-041

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@192707 936e1b1b-40f2-da11-902a-00137254ae57
2012-07-26 07:29:13 +00:00
Emmanuel Briot
91a4cf51a4 (Run_Command): cleanup handling of Hide_Output.
We now longer create and call our custom _gnatcoll class to redirect
 sys.stdout, sys.stderr and sys.displayhook. This method was fragile
 in the face of multi-tasking (L607-001). It was also hiding too
 much in fact, since it was often confusing for users that their
 "print" statements did not generate any output (L620-027).
Instead, we now compile with special flags with Py_CompileString,
 so that python does not generate the call to displayhook.
 Because of this, we cannot use __builtins__._ to look at the result
 of the previous command, but we get this output directly from
 PyEval_EvalCode when the code is an expression.
 One of the changes for users is that we can no longer execute a
 string containing a class or function definition or import statement,
 and expect to get its output (but in fact there is none, so the code
 was suspicious in the first place).
A few other optimizations in Run_Command (logging directly using the
 traces module, rather than through the console class), and avoid
 string manipulation when possible.
Provide support for logging exception messages in the log file, to
 help debug scripts.
Finally, this code is in preparation for support of python3 (L619-031)

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@191180 936e1b1b-40f2-da11-902a-00137254ae57
2012-06-20 19:23:03 +00:00
Emmanuel Briot
77bc259389 Ignore errors from gprclean (missing directories for instance)
git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@183686 936e1b1b-40f2-da11-902a-00137254ae57
2012-01-13 17:00:06 +00:00
Emmanuel Briot
b771c6813d Update GPL to version 3
KC20-012
Update copyright to 2012

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@182684 936e1b1b-40f2-da11-902a-00137254ae57
2011-12-20 09:32:09 +00:00
Emmanuel Briot
81e3a0a5e4 Fix testsuite on Windows: change the output of "-graph" in gnatcoll_db2ada
so that it doesn't include absolute paths

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@177053 936e1b1b-40f2-da11-902a-00137254ae57
2011-08-05 09:26:51 +00:00
Emmanuel Briot
b5b1528875 (Finalize): proper fix for reset (in the test)
K729-010

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@177041 936e1b1b-40f2-da11-902a-00137254ae57
2011-08-04 19:41:18 +00:00
Emmanuel Briot
a3b59386fb Complete documentation for GNATCOLL.SQL.ORM and associated example
Fix bug when the session is configured with Store_Unmodified set to False:
 when an element is retrieved through Get_Customer for instance, it isn't
 added to the session cache as per the settings. But then when we modify
 the element is still wasn't added to the cache because its session was
 already set. As a result the change was never committed to the database.
K729-010

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@177011 936e1b1b-40f2-da11-902a-00137254ae57
2011-08-04 15:09:47 +00:00
Emmanuel Briot
3db4e803a6 Complete documentation for GNATCOLL.SQL, and add to the library example
Fixes Storage_Error in sqlite support, where a prepared statement could
 be finalized before a cursor that used it. This is unlikely to occur in
 complex application where prepared statements are expected to be global
 variables, but would make the simple example more complex than need be
 (using subprograms or declare blocks to control the order of finalization)
K729-010

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@177001 936e1b1b-40f2-da11-902a-00137254ae57
2011-08-04 10:31:07 +00:00
Emmanuel Briot
a5976f1fc6 Further improvements to the GNATCOLL.SQL documentation
This now documents how to load a fixture file in the database, continuing
 the example started in the previous checkin
We also build this library example from the testsuite, to ensure the doc
 is still up-to-date
(GNATCOLL.SQL.Inspect.Read_Schema): change profile to make it easier to
 read a schema. This avoids the use of a declare block in the example and
 makes for more readable code.
K729-010

git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/trunk/gps@176969 936e1b1b-40f2-da11-902a-00137254ae57
2011-08-03 15:41:31 +00:00