Commit Graph

27 Commits

Author SHA1 Message Date
Tomasz Sowa 21f12a8a98
add support for declared cursors
Declare a cursor with the Finder::declare_cursor() method and next get the cursor with get_cursor():
morm::Cursor<MyObject> cursor = finder.
  declare_cursor("mycursorname").
  select().
  raw("ORDER BY column_name ASC").
  get_cursor();

The cursor now can be used with fetch.*() methods and then get() or get_list():
MyObject myobject = cursor.fetch_next().get();
std::list<MyObject> myobjects = cursor.fetch_forward_count(10).get_list();
2023-07-16 04:03:03 +02:00
Tomasz Sowa 1d4de8abe2 add support for nested transactions
while here:
- don't allow to copy/move DbConnector
2022-05-26 20:14:14 +02:00
Tomasz Sowa b32917afe7 use pikotools Log::put_multiline() method when printing PostgreSQL error messages 2022-05-25 19:58:13 +02:00
Tomasz Sowa 0ce7578de3 fix: the way how we test if there is a connection issue
If there is a connection issue then PQexec returns a resultset now
- older versions of PostgreSQL returned null pointer.
2022-05-25 19:11:42 +02:00
Tomasz Sowa 1ad4cb4fbd trim white lines after PostgreSQL error message 2022-05-24 20:06:06 +02:00
Tomasz Sowa 469294502e allow specify how many times we can try to connect to the database 2022-04-29 05:56:02 +02:00
Tomasz Sowa d384929e75 allow to use host connection parameter 2022-04-28 06:03:40 +02:00
Tomasz Sowa ac77abb8fd allow to use hostaddr, port or conn_string to connect to PostgreSQL 2022-04-20 18:36:06 +02:00
Tomasz Sowa 0bdabfc7b4 fix: put 'char' type directly to the output stream
Char type was converted to wchar_t and then was serialized as utf-8 stream.
Let char type will always be one char, of course it need to be a valid utf-8 sequence.

Let FT::dont_use_utf8 apply only to wchar_t and std::wstring
but ignore it if FT::hexadecimal or FT::binary are defined.

Now we have bool BaseExpression::esc_char(wchar_t val, pt::TextStream & stream) method
which (in most cases) will be used in derived classes.

Let wchar_t (and std::wstring) will be stored as 8 hex digits when using FT::hexadecimal
or FT::binary (and ignore FT::dont_use_utf8 in such a case).
2022-02-08 12:47:34 +01:00
Tomasz Sowa a8fe798279 fixed: getters method (Model::*getter_method)(pt::Stream &) produced boolean value when serializing to flat string
- changed in Model::field_list_generic(...): message "you should set FT::is_foreign_key or FT::is_foreign_key_in_child flag" print only
  for work mode MORM_MODEL_WORK_MODE_SET_PARENT_ID or MORM_MODEL_WORK_MODE_ITERATE_THROUGH_CHILDS_WITHOUT_FOREIGN_KEY
- pt::TextStream::to_string(...) is now pt::TextStream::to_str(...)
- in Model::get_raw_value() for ezc 'pt::TextStream & stream' changed to 'pt::Stream & stream' (a base class of pt::TextStream)
  similar in field(...) methods which take getters: void (Model::*getter_method)(pt::TextStream &) -> void (Model::*getter_method)(pt::Stream &)
2021-06-20 17:49:54 +02:00
Tomasz Sowa 0ff900f626 updated to the new pikotools api: changed utf8 functions PascalCase to snake_case 2021-05-21 00:32:29 +02:00
Tomasz Sowa 34274ca230 namespace PT renamed to pt 2021-05-20 16:25:01 +02:00
Tomasz Sowa 179be2864f change FT field_type in PostgreSQLConnector 2021-05-12 05:39:31 +02:00
Tomasz Sowa 009955a0fd added support for hex strings and binary strings
added FT::hexadecimal, FT::binary and FT::dont_use_utf8
2021-05-11 22:11:31 +02:00
Tomasz Sowa 2533b18cfd fixed: in cursor in add_models_to_list(): added_model.model_env should be set after added_model.clear()
fixed: when generating: insert, update or remove statements we have used prefixes for columns
       but the table name was not set in ModelEnv (now we do not use prefixes in such statements)
changed: log_queries field moved from PostgreSQLConnector to DbConnector





git-svn-id: svn://ttmath.org/publicrep/morm/branches/join_models@1195 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-06-17 10:59:39 +00:00
Tomasz Sowa 34ddf11351 some work in branches/join_models
git-svn-id: svn://ttmath.org/publicrep/morm/branches/join_models@1190 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-05-13 03:12:31 +00:00
Tomasz Sowa 79f9522708 used PT::Log::logsave in postgresqlconnector in some places
git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1181 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-03-19 17:54:33 +00:00
Tomasz Sowa eb3703c323 updated to the new pikotools api
(Logger -> Log)




git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1150 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-11-23 17:13:50 +00:00
Tomasz Sowa 8c5eaacadb changed: testing result status in do_query() in PostgreSQLConnector
renamed: some fields in QueryResult and PostgreSQLQueryResult




git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1142 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-11-15 08:50:10 +00:00
Tomasz Sowa 1f9e4ee70a added Cursor class
git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1140 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-11-14 17:14:26 +00:00
Tomasz Sowa cc2230001c added support for PT::Logger to DbConnector and PostgreSQLConnector
git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1097 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-23 15:46:21 +00:00
Tomasz Sowa 4c0d203fc8 added:
removing objects
saving objects (either insert or update or remove)





git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1091 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-22 01:26:46 +00:00
Tomasz Sowa 5bccb056d7 poprawka: get_value() z postgresqlconnector zamienione na get_value_from_result()
w klasie bazowej mamy virtualne get_value() z innymi parametrami
(ostrzeżenie kompilatora)




git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1087 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-19 11:37:10 +00:00
Tomasz Sowa ffb7ac85a6 added: QueryResult stack to PostgreSQLConnector
this allowes us to call query() recursively (from after_select() callback)



git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1085 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-18 10:22:01 +00:00
Tomasz Sowa 72b2622d08 some work in morm
- support for fetching rows from db
- support for inserting/updating rows



git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1081 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-16 22:46:25 +00:00
Tomasz Sowa 09f31b2803 some work in morm (select statement)
git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1079 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-15 23:00:17 +00:00
Tomasz Sowa d84ca900c3 reorganizing class hierarchy
git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1075 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-03-23 19:26:57 +00:00