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

Fix bug in locating fields when a JOIN clause is present #102

Merged
merged 9 commits into from
Jul 31, 2023

Conversation

mamcx
Copy link
Contributor

@mamcx mamcx commented Jul 26, 2023

Description of Changes

When a JOIN clause is presented before was constructed a new table name like TableA | TableB, this cause locating fields for TableA or TableB fails.

Also making more robust use of the hidden field OP_TYPE_FIELD_NAME, not assuming the location of it in the header.

Adding tracing for the SQL compilation step to see which SQL are running and more details in panics for subscription related to this PR.

API

  • This is a breaking change to the module API
  • This is a breaking change to the ClientAPI
  • This is a breaking change to the SDK API

If the API is breaking, please state below what will break

crates/lib/src/relation.rs Outdated Show resolved Hide resolved
crates/lib/src/relation.rs Outdated Show resolved Hide resolved
crates/lib/src/relation.rs Outdated Show resolved Hide resolved
crates/lib/src/relation.rs Outdated Show resolved Hide resolved
crates/core/src/subscription/subscription.rs Outdated Show resolved Hide resolved
crates/core/src/subscription/subscription.rs Outdated Show resolved Hide resolved
crates/core/src/subscription/subscription.rs Outdated Show resolved Hide resolved
crates/core/src/sql/ast.rs Outdated Show resolved Hide resolved
crates/core/src/subscription/query.rs Outdated Show resolved Hide resolved
crates/lib/src/relation.rs Show resolved Hide resolved
@@ -169,6 +169,9 @@ pub struct TableSchema {
}

impl TableSchema {
/// Check if the `name` of the [FieldName] exist on this [TableSchema]
///
/// Warning: It ignores the `table_name`
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm; the relevance of this comment isn't entirely clear to me. Could you elaborate on this?

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 will rework the field resolution because is broken now but is unrelated to the fix for this PR.

self.columns.iter().find(|x| x.col_name == name)
/// Check if the `col_name` exist on this [TableSchema]
///
/// Warning: It ignores the `table_name`
Copy link
Contributor

Choose a reason for hiding this comment

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

Same re. relevance.

mamcx and others added 9 commits July 27, 2023 14:50
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

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

LGTM + tested by Alessandro

@cloutiertyler cloutiertyler merged commit 333bbc3 into master Jul 31, 2023
4 checks passed
cloutiertyler pushed a commit that referenced this pull request Aug 1, 2023
* Fix bug in locating fields when a JOIN clause is present

* Update crates/lib/src/relation.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/lib/src/relation.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/subscription.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/subscription.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/subscription.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/query.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Small doc nits

* Fix test

---------

Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
cloutiertyler pushed a commit that referenced this pull request Aug 1, 2023
* Fix bug in locating fields when a JOIN clause is present

* Update crates/lib/src/relation.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/lib/src/relation.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/subscription.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/subscription.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/subscription.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/query.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Small doc nits

* Fix test

---------

Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
cloutiertyler pushed a commit that referenced this pull request Aug 1, 2023
* Fix bug in locating fields when a JOIN clause is present

* Update crates/lib/src/relation.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/lib/src/relation.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/subscription.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/subscription.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/subscription.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/subscription/query.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Small doc nits

* Fix test

---------

Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
@cloutiertyler cloutiertyler deleted the mamcx/bug_op_type branch August 1, 2023 21:54
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.

3 participants