@@ -43,7 +43,7 @@ bool Archive::ArchiveInstance(const ArchiveDef& definition,
43
43
return false ;
44
44
}
45
45
46
- auto statement = registration->GetInsertStatement ();
46
+ auto statement = registration->CreateInsertStatement ();
47
47
48
48
if (!statement.IsValid () || !statement.Reset ()) {
49
49
/*
@@ -52,21 +52,22 @@ bool Archive::ArchiveInstance(const ArchiveDef& definition,
52
52
return false ;
53
53
}
54
54
55
- auto itemName = archivable.GetArchiveName ();
55
+ auto primary_key = archivable.GetArchivePrimaryKey ();
56
56
57
57
/*
58
58
* The lifecycle of the archive item is tied to this scope and there is no
59
59
* way for the user to create an instance of an archive item. So its safe
60
60
* for its members to be references. It does not manage the lifetimes of
61
61
* anything.
62
62
*/
63
- ArchiveLocation item (*this , statement, *registration, itemName );
63
+ ArchiveLocation item (*this , statement, *registration, primary_key );
64
64
65
65
/*
66
66
* We need to bind the primary key only if the item does not provide its own
67
67
*/
68
68
if (!definition.auto_key &&
69
- !statement.WriteValue (ArchiveClassRegistration::NameIndex, itemName)) {
69
+ !statement.WriteValue (ArchiveClassRegistration::kPrimaryKeyIndex ,
70
+ primary_key)) {
70
71
return false ;
71
72
}
72
73
@@ -80,7 +81,7 @@ bool Archive::ArchiveInstance(const ArchiveDef& definition,
80
81
81
82
int64_t lastInsert = database_->GetLastInsertRowID ();
82
83
83
- if (!definition.auto_key && lastInsert != static_cast <int64_t >(itemName )) {
84
+ if (!definition.auto_key && lastInsert != static_cast <int64_t >(primary_key )) {
84
85
return false ;
85
86
}
86
87
@@ -122,7 +123,7 @@ size_t Archive::UnarchiveInstances(const ArchiveDef& definition,
122
123
123
124
const bool isQueryingSingle = name != ArchiveNameAuto;
124
125
125
- auto statement = registration->GetQueryStatement (isQueryingSingle);
126
+ auto statement = registration->CreateQueryStatement (isQueryingSingle);
126
127
127
128
if (!statement.IsValid () || !statement.Reset ()) {
128
129
return 0 ;
@@ -133,7 +134,8 @@ size_t Archive::UnarchiveInstances(const ArchiveDef& definition,
133
134
* If a single statement is being queried for, bind the name as a statement
134
135
* argument.
135
136
*/
136
- if (!statement.WriteValue (ArchiveClassRegistration::NameIndex, name)) {
137
+ if (!statement.WriteValue (ArchiveClassRegistration::kPrimaryKeyIndex ,
138
+ name)) {
137
139
return 0 ;
138
140
}
139
141
}
@@ -181,7 +183,7 @@ ArchiveLocation::ArchiveLocation(Archive& context,
181
183
name_(name),
182
184
current_class_(registration.GetClassName()) {}
183
185
184
- Archivable::ArchiveName ArchiveLocation::Name () const {
186
+ Archivable::ArchiveName ArchiveLocation::GetPrimaryKey () const {
185
187
return name_;
186
188
}
187
189
@@ -226,7 +228,7 @@ bool ArchiveLocation::Write(ArchiveDef::Member member,
226
228
}
227
229
228
230
/*
229
- * Bind the name of the serialiable
231
+ * Bind the name of the serializable
230
232
*/
231
233
if (!statement_.WriteValue (found.first , lastInsert)) {
232
234
return false ;
0 commit comments