[libgdamm] Added some methods.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdamm] Added some methods.
- Date: Sat, 16 Oct 2010 13:01:07 +0000 (UTC)
commit fbdd01f0a5f3d943ce5c42a12d936412a620c669
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Oct 16 14:39:59 2010 +0200
Added some methods.
* libgda/src/libgda_methods.defs: Regenerated with h2defs.py.
* libgda/src/connection.hg: Added quote_sql_identifier().
* libgda/src/dataselect.hg: Added rerun().
* libgda/src/metastore.hg: Added set_identifiers_style().
* libgda/src/sqlstatement.hg: Added string_to_type().
* libgda/src/sqlbuilder.hg: Added some documentation.
* tools/m4/convert_libgdamm.m4: Mention a new enum.
ChangeLog | 12 ++
libgda/src/connection.hg | 4 +
libgda/src/dataselect.hg | 2 +
libgda/src/libgda_methods.defs | 253 +++++++++++++++++++++++++++++++++++++++-
libgda/src/metastore.hg | 6 +-
libgda/src/sqlbuilder.hg | 80 +++++++++++--
libgda/src/sqlstatement.hg | 2 +-
tools/m4/convert_libgdamm.m4 | 1 +
8 files changed, 343 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bcd73a0..526f8fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-10-16 Murray Cumming <murrayc murrayc com>
+
+ Added some methods.
+
+ * libgda/src/libgda_methods.defs: Regenerated with h2defs.py.
+ * libgda/src/connection.hg: Added quote_sql_identifier().
+ * libgda/src/dataselect.hg: Added rerun().
+ * libgda/src/metastore.hg: Added set_identifiers_style().
+ * libgda/src/sqlstatement.hg: Added string_to_type().
+ * libgda/src/sqlbuilder.hg: Added some documentation.
+ * tools/m4/convert_libgdamm.m4: Mention a new enum.
+
2010-08-31 Murray Cumming <murrayc murrayc com>
Added ConfigError and Config::get_provider().
diff --git a/libgda/src/connection.hg b/libgda/src/connection.hg
index 65e91cd..cc36b12 100644
--- a/libgda/src/connection.hg
+++ b/libgda/src/connection.hg
@@ -351,6 +351,8 @@ public:
_WRAP_METHOD(Glib::RefPtr<ServerProvider> get_provider(), gda_connection_get_provider, refreturn)
_WRAP_METHOD(Glib::RefPtr<const ServerProvider> get_provider() const, gda_connection_get_provider, refreturn)
+ _WRAP_METHOD(Glib::ustring quote_sql_identifier(const Glib::ustring& id) const, gda_connection_quote_sql_identifier)
+
_WRAP_METHOD_DOCS_ONLY(gda_connection_statement_to_sql)
//TODO: Add an overload without the params_used.
@@ -359,6 +361,8 @@ public:
#else
Glib::ustring statement_to_sql(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params, StatementSqlFlag flags, std::list< Glib::RefPtr<Holder> >& params_used, std::auto_ptr<Glib::Error>& error) const;
#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ _IGNORE(gda_connection_internal_reset_transaction_status)
#m4 _CONVERSION(`GdaConnectionEvent*',`const Glib::RefPtr<ConnectionEvent>&',Glib::wrap($3, true))
_WRAP_SIGNAL(void error(const Glib::RefPtr<ConnectionEvent>& error), "error")
diff --git a/libgda/src/dataselect.hg b/libgda/src/dataselect.hg
index e6f1b21..ac0cccf 100644
--- a/libgda/src/dataselect.hg
+++ b/libgda/src/dataselect.hg
@@ -74,6 +74,8 @@ public:
_WRAP_METHOD(Glib::RefPtr<Connection> get_connection(), gda_data_select_get_connection)
+ _WRAP_METHOD(void rerun(), gda_data_select_rerun, errthrow)
+
_WRAP_PROPERTY("auto-reset", bool)
_WRAP_PROPERTY("store-all-rows", bool)
_WRAP_PROPERTY("connection", Glib::RefPtr<Connection>)
diff --git a/libgda/src/libgda_methods.defs b/libgda/src/libgda_methods.defs
index 865e503..a5a5a76 100644
--- a/libgda/src/libgda_methods.defs
+++ b/libgda/src/libgda_methods.defs
@@ -137,6 +137,34 @@
(gtype-id "GDA_TYPE_REPETITIVE_STATEMENT")
)
+(define-object ReportDocument
+ (in-module "Gda")
+ (parent "GObject")
+ (c-name "GdaReportDocument")
+ (gtype-id "GDA_TYPE_REPORT_DOCUMENT")
+)
+
+(define-object ReportDocbookDocument
+ (in-module "Gda")
+ (parent "GdaReportDocument")
+ (c-name "GdaReportDocbookDocument")
+ (gtype-id "GDA_TYPE_REPORT_DOCBOOK_DOCUMENT")
+)
+
+(define-object ReportEngine
+ (in-module "Gda")
+ (parent "GObject")
+ (c-name "GdaReportEngine")
+ (gtype-id "GDA_TYPE_REPORT_ENGINE")
+)
+
+(define-object ReportRmlDocument
+ (in-module "Gda")
+ (parent "GdaReportDocument")
+ (c-name "GdaReportRmlDocument")
+ (gtype-id "GDA_TYPE_REPORT_RML_DOCUMENT")
+)
+
(define-object Row
(in-module "Gda")
(parent "GObject")
@@ -370,6 +398,7 @@
'("sql-identifiers-case-sensitive" "GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE")
'("thread-safe" "GDA_CONNECTION_OPTIONS_THREAD_SAFE")
'("thread-isolated" "GDA_CONNECTION_OPTIONS_THREAD_ISOLATED")
+ '("auto-meta-data" "GDA_CONNECTION_OPTIONS_AUTO_META_DATA")
)
)
@@ -780,6 +809,7 @@
'("non-supported-error" "GDA_SERVER_PROVIDER_NON_SUPPORTED_ERROR")
'("server-version-error" "GDA_SERVER_PROVIDER_SERVER_VERSION_ERROR")
'("data-error" "GDA_SERVER_PROVIDER_DATA_ERROR")
+ '("default-value-handling-error" "GDA_SERVER_PROVIDER_DEFAULT_VALUE_HANDLING_ERROR")
)
)
@@ -791,6 +821,7 @@
'("xml-spec-error" "GDA_SET_XML_SPEC_ERROR")
'("holder-not-found-error" "GDA_SET_HOLDER_NOT_FOUND_ERROR")
'("invalid-error" "GDA_SET_INVALID_ERROR")
+ '("read-only-error" "GDA_SET_READ_ONLY_ERROR")
)
)
@@ -2083,6 +2114,15 @@
(return-type "gpointer")
)
+(define-method point_available_event
+ (of-object "GdaConnection")
+ (c-name "gda_connection_point_available_event")
+ (return-type "GdaConnectionEvent*")
+ (parameters
+ '("GdaConnectionEventType" "type")
+ )
+)
+
(define-method add_event
(of-object "GdaConnection")
(c-name "gda_connection_add_event")
@@ -4583,6 +4623,14 @@
)
)
+(define-function gda_server_operation_string_to_op_type
+ (c-name "gda_server_operation_string_to_op_type")
+ (return-type "GdaServerOperationType")
+ (parameters
+ '("const-gchar*" "str")
+ )
+)
+
(define-method get_node_info
(of-object "GdaServerOperation")
(c-name "gda_server_operation_get_node_info")
@@ -4730,7 +4778,7 @@
(c-name "gda_server_operation_add_item_to_sequence")
(return-type "guint")
(parameters
- '("const-gchar*" "path")
+ '("const-gchar*" "seq_path")
)
)
@@ -5159,6 +5207,16 @@
)
)
+(define-method replace_source_model
+ (of-object "GdaSet")
+ (c-name "gda_set_replace_source_model")
+ (return-type "none")
+ (parameters
+ '("GdaSetSource*" "source")
+ '("GdaDataModel*" "model")
+ )
+)
+
(define-method get_node
(of-object "GdaSet")
(c-name "gda_set_get_node")
@@ -5195,6 +5253,14 @@
)
)
+(define-function gda_set_new_read_only
+ (c-name "gda_set_new_read_only")
+ (return-type "GdaSet*")
+ (parameters
+ '("GSList*" "holders")
+ )
+)
+
;; From gda-sql-builder.h
@@ -5485,7 +5551,7 @@
(return-type "none")
(parameters
'("GdaSqlBuilderId" "limit_count_expr_id")
- '("GdaSqlBuilderId" "limit_offest_expr_id")
+ '("GdaSqlBuilderId" "limit_offset_expr_id")
)
)
@@ -6212,6 +6278,17 @@
)
)
+(define-method rewrite_for_default_values
+ (of-object "GdaStatement")
+ (c-name "gda_statement_rewrite_for_default_values")
+ (return-type "GdaSqlStatement*")
+ (parameters
+ '("GdaSet*" "params")
+ '("gboolean" "remove")
+ '("GError**" "error")
+ )
+)
+
(define-function gda_text_to_alphanum
(c-name "gda_text_to_alphanum")
(return-type "gchar*")
@@ -6753,6 +6830,12 @@
)
)
+(define-method valid
+ (of-object "GdaTime")
+ (c-name "gda_time_valid")
+ (return-type "gboolean")
+)
+
(define-function gda_timestamp_get_type
(c-name "gda_timestamp_get_type")
(return-type "GType")
@@ -6774,6 +6857,12 @@
)
)
+(define-method valid
+ (of-object "GdaTimestamp")
+ (c-name "gda_timestamp_valid")
+ (return-type "gboolean")
+)
+
(define-function gda_geometricpoint_get_type
(c-name "gda_geometricpoint_get_type")
(return-type "GType")
@@ -7201,6 +7290,16 @@
)
)
+(define-method check_validity_m
+ (of-object "GdaSqlStatement")
+ (c-name "gda_sql_statement_check_validity_m")
+ (return-type "gboolean")
+ (parameters
+ '("GdaMetaStruct*" "mstruct")
+ '("GError**" "error")
+ )
+)
+
(define-method check_clean
(of-object "GdaSqlStatement")
(c-name "gda_sql_statement_check_clean")
@@ -8001,3 +8100,153 @@
)
+
+;; From gda-report-docbook-document.h
+
+(define-function gda_report_docbook_document_get_type
+ (c-name "gda_report_docbook_document_get_type")
+ (return-type "GType")
+)
+
+(define-function gda_report_docbook_document_new
+ (c-name "gda_report_docbook_document_new")
+ (is-constructor-of "GdaReportDocbookDocument")
+ (return-type "GdaReportDocument*")
+ (parameters
+ '("GdaReportEngine*" "engine")
+ )
+)
+
+
+
+;; From gda-report-document.h
+
+(define-function gda_report_document_get_type
+ (c-name "gda_report_document_get_type")
+ (return-type "GType")
+)
+
+(define-method set_template
+ (of-object "GdaReportDocument")
+ (c-name "gda_report_document_set_template")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "file")
+ )
+)
+
+(define-method run_as_html
+ (of-object "GdaReportDocument")
+ (c-name "gda_report_document_run_as_html")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "filename")
+ '("GError**" "error")
+ )
+)
+
+(define-method run_as_pdf
+ (of-object "GdaReportDocument")
+ (c-name "gda_report_document_run_as_pdf")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "filename")
+ '("GError**" "error")
+ )
+)
+
+
+
+;; From gda-report-engine.h
+
+(define-function gda_report_engine_get_type
+ (c-name "gda_report_engine_get_type")
+ (return-type "GType")
+)
+
+(define-function gda_report_engine_new
+ (c-name "gda_report_engine_new")
+ (is-constructor-of "GdaReportEngine")
+ (return-type "GdaReportEngine*")
+ (parameters
+ '("xmlNodePtr" "spec_node")
+ )
+)
+
+(define-function gda_report_engine_new_from_string
+ (c-name "gda_report_engine_new_from_string")
+ (return-type "GdaReportEngine*")
+ (parameters
+ '("const-gchar*" "spec_string")
+ )
+)
+
+(define-function gda_report_engine_new_from_file
+ (c-name "gda_report_engine_new_from_file")
+ (return-type "GdaReportEngine*")
+ (parameters
+ '("const-gchar*" "spec_file_name")
+ )
+)
+
+(define-method declare_object
+ (of-object "GdaReportEngine")
+ (c-name "gda_report_engine_declare_object")
+ (return-type "none")
+ (parameters
+ '("GObject*" "object")
+ '("const-gchar*" "obj_name")
+ )
+)
+
+(define-method find_declared_object
+ (of-object "GdaReportEngine")
+ (c-name "gda_report_engine_find_declared_object")
+ (return-type "GObject*")
+ (parameters
+ '("GType" "obj_type")
+ '("const-gchar*" "obj_name")
+ )
+)
+
+(define-method run_as_node
+ (of-object "GdaReportEngine")
+ (c-name "gda_report_engine_run_as_node")
+ (return-type "xmlNodePtr")
+ (parameters
+ '("GError**" "error")
+ )
+)
+
+(define-method run_as_doc
+ (of-object "GdaReportEngine")
+ (c-name "gda_report_engine_run_as_doc")
+ (return-type "xmlDocPtr")
+ (parameters
+ '("GError**" "error")
+ )
+)
+
+
+
+;; From gda-report-rml-document.h
+
+(define-function gda_report_rml_document_get_type
+ (c-name "gda_report_rml_document_get_type")
+ (return-type "GType")
+)
+
+(define-function gda_report_rml_document_new
+ (c-name "gda_report_rml_document_new")
+ (is-constructor-of "GdaReportRmlDocument")
+ (return-type "GdaReportDocument*")
+ (parameters
+ '("GdaReportEngine*" "engine")
+ )
+)
+
+
+
+;; From libgda-report.h
+
+
diff --git a/libgda/src/metastore.hg b/libgda/src/metastore.hg
index 7a26236..fb7e32f 100644
--- a/libgda/src/metastore.hg
+++ b/libgda/src/metastore.hg
@@ -32,6 +32,7 @@ namespace Gda
{
_WRAP_GERROR(MetaStoreError, GdaMetaStoreError, GDA_META_STORE_ERROR)
+_WRAP_ENUM(SqlIdentifierStyle, GdaSqlIdentifierStyle)
/** Dictionary object.
*
@@ -80,6 +81,7 @@ public:
_WRAP_METHOD(bool modify_with_context (MetaContext* context, const Glib::RefPtr<DataModel>& new_data), gda_meta_store_modify_with_context, errthrow)
_WRAP_METHOD(Glib::RefPtr<DataModel> create_modify_data_model(const Glib::ustring& table_name), gda_meta_store_create_modify_data_model)
+ _WRAP_METHOD(void set_identifiers_style(SqlIdentifierStyle style), gda_meta_store_set_identifiers_style)
_WRAP_METHOD(Glib::RefPtr<MetaStruct> schema_get_structure(), gda_meta_store_schema_get_structure, errthrow)
_WRAP_METHOD(Glib::SListHandle<Glib::ustring> schema_get_all_tables(), gda_meta_store_schema_get_all_tables)
_WRAP_METHOD(Glib::SListHandle<Glib::ustring> schema_get_depend_tables(const Glib::ustring& table_name), gda_meta_store_schema_get_depend_tables)
@@ -98,7 +100,9 @@ public:
_WRAP_METHOD(Glib::RefPtr<Connection> get_internal_connection(), gda_meta_store_get_internal_connection)
_WRAP_METHOD(Glib::RefPtr<const Connection> get_internal_connection() const, gda_meta_store_get_internal_connection)
- // The rest of the properties is Write / Construct Only
+ _IGNORE(gda_meta_store_set_reserved_keywords_func)
+
+ // The rest of the properties are Write / Construct-only
_WRAP_PROPERTY("cnc", Glib::RefPtr<Connection>)
_WRAP_SIGNAL(void meta_reset(), "meta-reset")
diff --git a/libgda/src/sqlbuilder.hg b/libgda/src/sqlbuilder.hg
index a4e5d49..239cedb 100644
--- a/libgda/src/sqlbuilder.hg
+++ b/libgda/src/sqlbuilder.hg
@@ -37,8 +37,37 @@ _WRAP_ENUM(SqlSelectJoinType, GdaSqlSelectJoinType)
_WRAP_GERROR(SqlBuilderError, GdaSqlBuilderError, GDA_SQL_BUILDER_ERROR)
_WRAP_GERROR(SqlError, GdaSqlError, GDA_SQL_ERROR)
-/*
- * @ingroup Connection
+/** SqlBuilder can be used to build a Statement from its structural description,
+ * much in the same way a SqlParser can be used to build a Statement from a SQL string.
+ *
+ * You may, for instance, pass the SqlBuilder directly to
+ * Connection::statement_execute_select_builder() or
+ * statement_execute_non_select_builder(). Or you may instead call
+ * get_statement() and use the resulting SqlStatement.
+ *
+ * During the building process, some pieces of the statement are constructed
+ * and assembled into the final statement. Each of these pieces can be reused
+ * anytime in the same SqlBuilder object, and each is identified using a
+ * single ID. That ID is dynamically allocated by the object.
+ *
+ * This simple example builds the equivalent of this SQL query:
+ * "SELECT employees.name_first, employees.name_last FROM employees WHERE employees.employee_id = 123".
+ *
+ * @code
+ * Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
+ * Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
+ * builder->select_add_field("name_fist", "employees");
+ * builder->select_add_field("name_last", "employees");
+ * builder->select_add_target("employees");
+ * builder->set_where(
+ * builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ * builder->add_field_id("employee_id", "employees"),
+ * builder->add_expr(123)));
+ * @endcode
+ *
+ * Note that, in this simple example, it's not necessary to specify the extra
+ * "employees" table name parameter to select_add_field() and add_field_id(),
+ * though it's often a good idea to avoid ambiguity in larger queries.
*/
class SqlBuilder : public Glib::Object
{
@@ -148,26 +177,37 @@ public:
*/
Id add_function(const Glib::ustring& function_name, const Glib::ArrayHandle<Id>& args);
- /** Builds a new expression which represents a function applied to an argument.
- *
- * @param function_name The name of the function to embed (e.g. MAX, MIN, ...)
- * @param arg: The ids of the argument to the function
- *
- * @return The ID of the new target, or 0 if there was an error.
- */
+ /** Builds a new expression which represents a function applied to an argument.
+ *
+ * @param function_name The name of the function to embed (e.g. MAX, MIN, ...)
+ * @param arg: The ids of the argument to the function
+ *
+ * @return The ID of the new target, or 0 if there was an error.
+ */
Id add_function(const Glib::ustring& function_name, Id arg);
+ /** Adds an expression which is a subselect.
+ *
+ * @param sqlst A SqlStatement, which must be a SELECT or compound SELECT.
+ * @return The ID of the new expression, or 0 if there was an error.
+ */
Id add_sub_select(const SqlStatement& sqlst);
_IGNORE(gda_sql_builder_add_sub_select)
//TODO: _WRAP_METHOD(Id gda_sql_builder_add_case (GdaSqlBuilder *builder, Id id, Id test_expr, Id else_expr, ...);
//TODO: _WRAP_METHOD(Id gda_sql_builder_add_case_v (GdaSqlBuilder *builder, Id id, Id test_expr, Id else_expr, const Id *when_array, const Id *then_array, gint args_size);
+ //TODO: Id add_case(Id id, Id test_expr, Id else_expr, const type_case_pairs& case_pairs);
+ //_IGNORE(gda_sql_builder_add_case)
+
+
+
_WRAP_METHOD(Id select_add_field(const Glib::ustring& field_name, const Glib::ustring& table_name, const Glib::ustring& alias = Glib::ustring()), gda_sql_builder_select_add_field)
// Statement API
- /** Adds a new target to a SELECT statement
+ /** Adds a new target to a SELECT statement.
+ *
* @param table_id The ID of the expression holding a table reference.
* @param alias The alias to give to the target.
*
@@ -180,7 +220,8 @@ public:
Id select_add_target_id(Id table_id, const Glib::ustring& alias = Glib::ustring());
_IGNORE(gda_sql_builder_select_add_target_id)
- /** Joins two targets in a SELECT statement
+ /** Joins two targets in a SELECT statement.
+ *
* @param left_target_id The ID of the left target to use (not %0)
* @param right_target_id The ID of the right target to use (not %0)
* @param join_type The type of join
@@ -202,10 +243,11 @@ public:
_WRAP_METHOD(void select_set_distinct(bool distinct, Id expr_id), gda_sql_builder_select_set_distinct)
/** Defines the maximum number of rows in the DataModel resulting from the execution of the built statement.
+ *
* @param limit_count The number of rows that should be returned.
* @param The offset of the first row that should appear in the result. (note that
* this feature may not be supported by all the database providers.)
- */
+ */
void select_set_limit(Id limit_count, Id offset = 0);
_WRAP_METHOD(void select_set_limit_id(Id limit_count_expr_id, Id limit_offest_expr_id = 0), gda_sql_builder_select_set_limit)
@@ -221,7 +263,13 @@ public:
_WRAP_METHOD(void add_field_value_id(Id field_id, Id value_id = 0), gda_sql_builder_add_field_value_id)
- //TODO: Documentation:
+ /** Specifies that the field represented by @a field_name will be set to the @a value.
+ * See gadd_expr() for more information.
+ * This is valid only for INSERT and UPDATE statements.
+ *
+ * @parm field_name A field name.
+ * @param value The value to set the field to.
+ */
template <class ValueType>
void add_field_value(const Glib::ustring& field_name, const ValueType& value);
@@ -235,6 +283,12 @@ public:
_WRAP_METHOD(SqlExpr export_expression(Id id) const, gda_sql_builder_export_expression)
+ //TODO: This is a crappy description.
+ /** Imports the expression.
+ *
+ * @param expr A SqlExpr obtained using export_expression().
+ * @return The ID of the new expression, or 0 if there was an error.
+ */
Id import_expression(const SqlExpr& expr);
_IGNORE(gda_sql_builder_import_expression)
};
diff --git a/libgda/src/sqlstatement.hg b/libgda/src/sqlstatement.hg
index cb81cbf..e155448 100644
--- a/libgda/src/sqlstatement.hg
+++ b/libgda/src/sqlstatement.hg
@@ -49,7 +49,7 @@ public:
_WRAP_METHOD(Glib::ustring serialize() const, gda_sql_statement_serialize)
//_WRAP_METHOD(static Glib::ustring type_to_string(SqlStatementType type), gda_sql_statement_type_to_string)
- //_WRAP_METHOD(static SqlStatementType string_to_type (const Glib::ustring& type), gda_sql_statement_string_to_type)
+ _WRAP_METHOD(static SqlStatementType string_to_type(const Glib::ustring& type), gda_sql_statement_string_to_type)
_WRAP_METHOD(bool check_structure() const, gda_sql_statement_check_structure, errthrow)
_WRAP_METHOD(bool check_validity(const Glib::RefPtr<Connection>& cnc), gda_sql_statement_check_validity, errthrow)
diff --git a/tools/m4/convert_libgdamm.m4 b/tools/m4/convert_libgdamm.m4
index 8ed27c0..89c8f5f 100644
--- a/tools/m4/convert_libgdamm.m4
+++ b/tools/m4/convert_libgdamm.m4
@@ -130,6 +130,7 @@ _CONV_ENUM(Gda,SqlParserError)
_CONV_ENUM(Gda,SqlOperatorType)
_CONV_ENUM(Gda,SqlSelectJoinType)
_CONV_ENUM(Gda,SqlStatementType)
+_CONV_ENUM(Gda,SqlIdentifierStyle)
# structs
_CONVERSION(`Blob&',`GdaBlob*',__FR2P)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]