@@ -43,7 +43,7 @@ bool Archive::ArchiveInstance(const ArchiveDef& definition,
4343 return false ;
4444 }
4545
46- auto statement = registration->GetInsertStatement ();
46+ auto statement = registration->CreateInsertStatement ();
4747
4848 if (!statement.IsValid () || !statement.Reset ()) {
4949 /*
@@ -52,21 +52,22 @@ bool Archive::ArchiveInstance(const ArchiveDef& definition,
5252 return false ;
5353 }
5454
55- auto itemName = archivable.GetArchiveName ();
55+ auto primary_key = archivable.GetArchivePrimaryKey ();
5656
5757 /*
5858 * The lifecycle of the archive item is tied to this scope and there is no
5959 * way for the user to create an instance of an archive item. So its safe
6060 * for its members to be references. It does not manage the lifetimes of
6161 * anything.
6262 */
63- ArchiveLocation item (*this , statement, *registration, itemName );
63+ ArchiveLocation item (*this , statement, *registration, primary_key );
6464
6565 /*
6666 * We need to bind the primary key only if the item does not provide its own
6767 */
6868 if (!definition.auto_key &&
69- !statement.WriteValue (ArchiveClassRegistration::NameIndex, itemName)) {
69+ !statement.WriteValue (ArchiveClassRegistration::kPrimaryKeyIndex ,
70+ primary_key)) {
7071 return false ;
7172 }
7273
@@ -80,7 +81,7 @@ bool Archive::ArchiveInstance(const ArchiveDef& definition,
8081
8182 int64_t lastInsert = database_->GetLastInsertRowID ();
8283
83- if (!definition.auto_key && lastInsert != static_cast <int64_t >(itemName )) {
84+ if (!definition.auto_key && lastInsert != static_cast <int64_t >(primary_key )) {
8485 return false ;
8586 }
8687
@@ -122,7 +123,7 @@ size_t Archive::UnarchiveInstances(const ArchiveDef& definition,
122123
123124 const bool isQueryingSingle = name != ArchiveNameAuto;
124125
125- auto statement = registration->GetQueryStatement (isQueryingSingle);
126+ auto statement = registration->CreateQueryStatement (isQueryingSingle);
126127
127128 if (!statement.IsValid () || !statement.Reset ()) {
128129 return 0 ;
@@ -133,7 +134,8 @@ size_t Archive::UnarchiveInstances(const ArchiveDef& definition,
133134 * If a single statement is being queried for, bind the name as a statement
134135 * argument.
135136 */
136- if (!statement.WriteValue (ArchiveClassRegistration::NameIndex, name)) {
137+ if (!statement.WriteValue (ArchiveClassRegistration::kPrimaryKeyIndex ,
138+ name)) {
137139 return 0 ;
138140 }
139141 }
@@ -181,7 +183,7 @@ ArchiveLocation::ArchiveLocation(Archive& context,
181183 name_(name),
182184 current_class_(registration.GetClassName()) {}
183185
184- Archivable::ArchiveName ArchiveLocation::Name () const {
186+ Archivable::ArchiveName ArchiveLocation::GetPrimaryKey () const {
185187 return name_;
186188}
187189
@@ -226,7 +228,7 @@ bool ArchiveLocation::Write(ArchiveDef::Member member,
226228 }
227229
228230 /*
229- * Bind the name of the serialiable
231+ * Bind the name of the serializable
230232 */
231233 if (!statement_.WriteValue (found.first , lastInsert)) {
232234 return false ;
0 commit comments