Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add REGISTER_AUTO_KEY #129

Merged
merged 7 commits into from
Dec 4, 2023
Merged

add REGISTER_AUTO_KEY #129

merged 7 commits into from
Dec 4, 2023

Conversation

Jacyking
Copy link
Collaborator

@Jacyking Jacyking commented Dec 3, 2023

struct person {
  std::optional<std::string> name;
  std::optional<int> age;
  int id;
};
REGISTER_AUTO_KEY(person, id)
REFLECTION(person, id, name, age)

REGISTER_AUTO_KEY(person, id) used to set which field is the auto increment key;

for PG:

struct student {
  int code;
  std::string name;
  char sex;
  int age;
  double dm;
  std::string classroom;
};
#ifdef ORMPP_ENABLE_PG
REGISTER_CONFLICT_KEY(student, code)
#endif
REFLECTION(student, code, name, sex, age, dm, classroom)

REGISTER_CONFLICT_KEY(student, code) only for PG: insert with update, more details:
https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-upsert/

@codecov-commenter
Copy link

codecov-commenter commented Dec 3, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cf53076) 39.88% compared to head (47cedd8) 40.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #129      +/-   ##
==========================================
+ Coverage   39.88%   40.00%   +0.12%     
==========================================
  Files          22       22              
  Lines        2856     2867      +11     
==========================================
+ Hits         1139     1147       +8     
- Misses       1717     1720       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@qicosmos
Copy link
Owner

qicosmos commented Dec 4, 2023

REGISTER_CONFLICT_KEY
这个是PG里面专有的吗,我还不知道这个干啥的,为啥要加这个,在pr描述里加一段文字介绍吧,

@Jacyking
Copy link
Collaborator Author

Jacyking commented Dec 4, 2023

REGISTER_CONFLICT_KEY 这个是PG里面专有的吗,我还不知道这个干啥的,为啥要加这个,在pr描述里加一段文字介绍吧,

[ WITH [ RECURSIVE ] with_query [, ...] ] INSERT INTO table_name [ ( column_name [, ...] ) ] { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } [ ON CONFLICT [ ( { column_name_index | ( expression_index ) } [ COLLATE collation ] [ opclass ] [, ...] [ WHERE index_predicate ] ) ] { IGNORE | UPDATE SET { column_name = { expression | DEFAULT } | ( column_name [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [, ...] [ WHERE condition ] } ] [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]

https://wiki.postgresql.org/wiki/UPSERT#SQLite:...ON_CONFLICT....2F_INSERT.2FUPDATE_...OR...

@qicosmos qicosmos self-requested a review December 4, 2023 03:21
Copy link
Owner

@qicosmos qicosmos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Jacyking Jacyking merged commit 9f4d00c into qicosmos:master Dec 4, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants