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

Unknown computed column type #5377

Merged
merged 4 commits into from
Jan 9, 2024

Conversation

boutinb
Copy link
Contributor

@boutinb boutinb commented Jan 8, 2024

The computedColumnType 'unknown' does not exist anymore, but might be stored in the database. So we need to take care of this.
Fixes jasp-stats/jasp-issues#2517

@boutinb boutinb requested a review from JorisGoosen January 8, 2024 12:09
@boutinb boutinb changed the base branch from development to stable January 8, 2024 12:10
The computedColumnType 'unknown' does not exist anymore, but might be stored in the database. So we need to take care of this.
Fixes jasp-stats/jasp-issues#2517
@boutinb boutinb force-pushed the unknwonCoputedColumnType branch from 0f1f0e7 to 8c00755 Compare January 8, 2024 12:13
@boutinb boutinb changed the title Unknwon coputed column type Unknown computed column type Jan 8, 2024
Comment on lines 68 to 84
const std::string & rCode = json["rCode"].asString();

const std::string & rCode = json["rCode"].asString(),
& codeTypeStr = json["codeType"].asString();

computedColumnType codeType = computedColumnType::notComputed;
if (!codeTypeStr.empty())
{
try { codeType = computedColumnTypeFromString(codeTypeStr); }
catch(...) {}
}

try { codeType = computedColumnTypeFromString(codeTypeStr); } catch(...) {}

setCompColStuff
(
json["invalidated"].asBool(),
computedColumnTypeFromString(json["codeType"].asString()),
codeType,
rCode,
Copy link
Contributor

Choose a reason for hiding this comment

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

You dont need to make changes to column.cpp I think?

Just the change to DatabaseInterface::columnGetComputedInfo should be enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was not quite completely sure that this error could not arise here. For the case, it does not hurt I fimd.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah but if the changes are not necessary at all why make them?

@JorisGoosen
Copy link
Contributor

Ah while testing I found that loading the jasp file from the issue with the current PR gets:
image

So it is "not computed" yet it is computed according to the columnheader.

So this is not really a fix yet.

@JorisGoosen
Copy link
Contributor

the question is more, how can unknown even be written there? Or was that simply the default when we didnt set it before?
How is it possible that a column was stored with unknown as computed column type at all?

This has a rootcause and we need to figure it out how it happened.

Also, to expand this workaround it would perhaps be good to check in DatabaseInterface::columnGetComputedInfo whether the computedColumnType isnt notComputed before returning true (because that says: isComputed)

@boutinb
Copy link
Contributor Author

boutinb commented Jan 8, 2024

the question is more, how can unknown even be written there? Or was that simply the default when we didnt set it before? How is it possible that a column was stored with unknown as computed column type at all?

This has a rootcause and we need to figure it out how it happened.

When I open the file in 0.18.1, then I see also a not computed column with an icon telling this is a computed column. So the situation was buggy in 0.18.1. The rcode of this column is also empty.
I have tried to reproduce this in 0.18.1 by undo/redo, copy/paste, but could not find a way to get such a situation.
But the code should be better in 0.18.2! So we can expect that this is not reproducible anyway.

The isComputed column in the database is not needed anymore. So I would just remove it.

@JorisGoosen
Copy link
Contributor

The isComputed column in the database is not needed anymore. So I would just remove it.

Ok so remove it in void DatabaseInterface::upgradeDBFromVersion(Version originalVersion)
By adding something to it like:

	   if(originalVersion < "0.18.2")
			   runStatements("ALTER TABLE DataSets ADD COLUMN description     TEXT;"                 "\n");

	   if(originalVersion < "0.18.3")
			   runStatements("ALTER TABLE Columns DROP COLUMN isComputed;"                 "\n");

And then remove it from all the functions that expect it...

You want this to be a hotfix or a potential place to create more bugs though? ;)

@boutinb
Copy link
Contributor Author

boutinb commented Jan 8, 2024

Hmm by removing isColumn in the database, we have then a downgrade issue: JASP file made in 0.18.3 won't be readable in 0.18.2 or lower... This is not expected for a minor release. So I will let the isColumn in the database. We can remove it in 0.19

@JorisGoosen
Copy link
Contributor

Exactly, however, you still need to fix the output of that function then. The best thing would be to make sure that if the computedColumnType is "notComputed" the isComputed thing is set FALSE

the _isColumn property of Column class can be deduced by the codeType property, so remove it from the class.
However for downgrade purpose, the isColumn column in the database is kept so that JASP file made in 0.18.3 can be still read in 0.18.2 or 0.18.1.
@boutinb
Copy link
Contributor Author

boutinb commented Jan 8, 2024

I have removed the _isColumn property of the Column class, as it can be deduced by the codeType property
However for downgrade purpose, the isColumn column in the database is kept so that JASP file made in 0.18.3 can be still read in 0.18.2 or 0.18.1.

@JorisGoosen JorisGoosen merged commit fc73f32 into jasp-stats:stable Jan 9, 2024
1 check failed
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.

[Bug]: .jasp file does not open / load after downloading 0.18.2
2 participants