mathesar icon indicating copy to clipboard operation
mathesar copied to clipboard

Extracting columns that aren't orderable into a different tables results in incorrect data

Open silentninja opened this issue 2 years ago • 20 comments

Description

Extracting columns that aren't orderable (e.g., JSON) into a different table using the move_column or split_table feature results in incorrect data.

Expected behavior

We should be able to move columns that aren't orderable or give a correct error response if it is not possible.

Suggested solution

Detect when the column being moved is not orderable and throw an error.

silentninja avatar Aug 01 '22 17:08 silentninja

#1436 needs to be merged for this bug to be valid, marking it as draft until then

silentninja avatar Aug 01 '22 17:08 silentninja

For context, we've a predicate function (currently it's private) that tells you if a column is orderable: https://github.com/centerofci/mathesar/blob/73458a90fce21975e87761af32e2a38b59b274e6/db/records/operations/sort.py#L68

dmos62 avatar Mar 21 '23 12:03 dmos62

I'd like to work on this issue, can you assign it to me?

Reireirei0 avatar Mar 22 '23 14:03 Reireirei0

@Reireirei0 sure please go ahead.

Since this will be your first contribution please read our contributing guide here: https://wiki.mathesar.org/en/community/contributing

rajatvijay avatar Mar 23 '23 11:03 rajatvijay

@Reireirei0 to quickly expand on what @rajatvijay said, we're currently not assigning issues to new contributors that don't yet have any PRs (open or closed). This is so that if a contributor were to disappear, that wouldn't block other contributors from picking up the issue he was working on (this is explained in the link @rajatvijay gave).

dmos62 avatar Mar 23 '23 12:03 dmos62

@dmos62 Thanks for your explanation~

Reireirei0 avatar Mar 24 '23 06:03 Reireirei0

@dmos62 @silentninja

check my modification, is this the desired solution?

def _is_col_orderable(col):

data_type = col.type
non_orderable_type = ['Binary', 'LargeBinary', 'PickleType', 'ARRAY', 'JSON', 'JSONB']
if str(data_type) in non_orderable_type:
    raise ValueError("Column is not orderable.")
return True

thesujai avatar Mar 25 '23 15:03 thesujai

Can you assign me this issue please? @silentninja

7ashraf avatar Mar 26 '23 11:03 7ashraf

@7ashraf no. See https://github.com/centerofci/mathesar/issues/1490#issuecomment-1481147668

rajatvijay avatar Mar 26 '23 18:03 rajatvijay

@thesujai you'll want to provide tests that make sure the problem is fixed. Please post a PR before asking for review.

dmos62 avatar Mar 27 '23 10:03 dmos62

@silentninja Where are move_column or split_table function, I want to add try and except logic to this (_is_col_orderable) function.

ShailRT avatar Mar 28 '23 19:03 ShailRT

hey! can I still work on this if the pr is not merged yet?

shivansii avatar Mar 30 '23 00:03 shivansii

@shivansii yes, go ahead.

dmos62 avatar Mar 30 '23 09:03 dmos62

@dmos62 I am happy to help with this issue. Can I work on it?

esing1201 avatar Apr 10 '23 01:04 esing1201

@esing1201 yes.

dmos62 avatar Apr 11 '23 08:04 dmos62

Hi, I would like to start working on this issue.

raisachatterjee avatar Sep 07 '23 11:09 raisachatterjee

Unassigning due to inactivity

seancolsen avatar Nov 01 '23 19:11 seancolsen

@seancolsen @seancolsen could you please assign it to me?

rai-ankur avatar Jan 01 '24 13:01 rai-ankur

@rai-ankur You're welcome to work on this and submit a PR, but in general we don't assign tickets to new contributors, as noted in our Contributor Guide. Once we've already merged a PR of yours, then we'll be happy to assign tickets to you after that. The reason for this policy is that in the past it has been a maintenance burden for us to manage ticket assignments while having an overwhelming volume of people fail to submit their first PR when initially expressing intent to contribute.

seancolsen avatar Jan 02 '24 14:01 seancolsen

I've added the db-layer label since the split_tables function is implemented purely in SQL now.

mathemancer avatar Jan 05 '24 04:01 mathemancer