Skip to content

Merge versioned sets and problems with their version 0 template. - #3309

Open
drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:bugfix/version-merge
Open

drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:bugfix/version-merge

Conversation

@drgrice1

Copy link
Copy Markdown
Member

A merged set or problem version was not including the version 0 template row from the set_user/problem_user table: the generic keyfield join in the Merge schema matched version_id between the primary (version) table and the lower priority tables, so the template row (version 0) never matched the version row.

This is an alternate approach to #3308. The problem with that pull request is that specialized code with dealing with the versioned merge should not be in the WeBWorK::DB::Schema::NewSQL::Merge base package. It should be handled in the WeBWorK::DB::Schema::NewSQL::Versioned package. This keeps the WeBWorK::DB::Schema::NewSQL::Merge package generic by delegating each keyfield join term to the primary schema's new merge_keyfield_where method. The Versioned schema overrides it so that the lower priority template tables are matched at version 0 for the version_id field.

A merged set or problem version was not including the version 0 template
row from the set_user/problem_user table: the generic keyfield join in
the Merge schema matched version_id between the primary (version) table
and the lower priority tables, so the template row (version 0) never
matched the version row.

This is an alternate approach to openwebwork#3308.  The problem with that pull
request is that specialized code with dealing with the versioned merge
should not be in the `WeBWorK::DB::Schema::NewSQL::Merge` base package.
It should be handled in the `WeBWorK::DB::Schema::NewSQL::Versioned`
package. This keeps the `WeBWorK::DB::Schema::NewSQL::Merge` package
generic by delegating each keyfield join term to the primary schema's
new merge_keyfield_where method. The Versioned schema overrides it so
that the lower priority template tables are matched at version 0 for the
version_id field.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@drgrice1

Copy link
Copy Markdown
Member Author

Actually hold on this and #3308. Both are not right. I am looking at this closer.

@drgrice1

Copy link
Copy Markdown
Member Author

Okay, nevermind my last comment. This is right.

@somiaj

somiaj commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Think a different name than merge_keyfield_where for the method would be appropriate? It is only used for the where clause, but the method just sets name=value, so feels the name could be more generic about what it does vs how it used?

@somiaj

somiaj commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Though I guess it wouldn't make sense to use this outside of a merge where statement (since it deals with template version), so probably best to not be too generic. Anyway, just a thought while trying to understand the code.

@drgrice1

Copy link
Copy Markdown
Member Author

The merge_keyfield_where method is intended to be used only to obtain the where clause for the keyfield of a merge table. It certainly should not be called anywhere else. Its default method is defined in the WeBWorK::DB::Schema::NewSQL::Std package and can be overridden in a package that derives from that such as the WeBWorK::DB::Schema::NewSQL::Versioned package. As such it is named appropriately.

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.

2 participants