-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: Problem in the description field when using the MariaDB or MySQL #3431
Conversation
fix: Problem in the description field when using the MariaDB or MySQL.
Pull Request Validation ReportThis comment is automatically generated by Conventional PR Whitelist Report
Result Pull request does not satisfy any enabled whitelist criteria. Pull request will be validated. Validation Report
Result Pull request satisfies all enabled pull request rules. Last Modified at 19 Aug 24 18:07 UTC |
This pull request is automatically being deployed by Amplify Hosting (learn more). |
fix: Problem in the description field when using the MariaDB or MySQL…
Thanks for this PR. We just need to add the migration script to it. The steps should be: """Update description columns type
Revision ID: 4522eb831f5c
Revises: 0d60fcbd4e8e
Create Date: 2024-08-20 11:15:58.282318
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
from langflow.utils import migration
from sqlalchemy.engine.reflection import Inspector
# revision identifiers, used by Alembic.
revision: str = "4522eb831f5c"
down_revision: Union[str, None] = "0d60fcbd4e8e"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
conn = op.get_bind()
# ### commands auto generated by Alembic - please adjust! ###
inspector = Inspector.from_engine(conn) # type: ignore
with op.batch_alter_table("flow", schema=None) as batch_op:
if migration.column_exists(table_name="flow", column_name="description", conn=conn):
columns = inspector.get_columns("flow")
description_column = next((column for column in columns if column["name"] == "description"), None)
if description_column is not None and isinstance(description_column["type"], sa.VARCHAR):
batch_op.alter_column(
"description", existing_type=sa.VARCHAR(), type_=sa.Text(), existing_nullable=True
)
with op.batch_alter_table("folder", schema=None) as batch_op:
if migration.column_exists(table_name="flow", column_name="description", conn=conn):
columns = inspector.get_columns("folder")
description_column = next((column for column in columns if column["name"] == "description"), None)
if description_column is not None and isinstance(description_column["type"], sa.VARCHAR):
batch_op.alter_column(
"description", existing_type=sa.VARCHAR(), type_=sa.Text(), existing_nullable=True
)
# ### end Alembic commands ###
def downgrade() -> None:
conn = op.get_bind()
# ### commands auto generated by Alembic - please adjust! ###
inspector = Inspector.from_engine(conn) # type: ignore
with op.batch_alter_table("folder", schema=None) as batch_op:
if migration.column_exists(table_name="folder", column_name="description", conn=conn):
columns = inspector.get_columns("folder")
description_column = next((column for column in columns if column["name"] == "description"), None)
if description_column is not None and isinstance(description_column["type"], sa.VARCHAR):
batch_op.alter_column(
"description", existing_type=sa.VARCHAR(), type_=sa.Text(), existing_nullable=True
)
with op.batch_alter_table("flow", schema=None) as batch_op:
if migration.column_exists(table_name="flow", column_name="description", conn=conn):
columns = inspector.get_columns("flow")
description_column = next((column for column in columns if column["name"] == "description"), None)
if description_column is not None and isinstance(description_column["type"], sa.VARCHAR):
batch_op.alter_column(
"description", existing_type=sa.VARCHAR(), type_=sa.Text(), existing_nullable=True
)
# ### end Alembic commands ### Make sure everything is working and commit ;) |
fix: Add the migration script to update description columns type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
we'll add the migrations
src/backend/base/langflow/alembic/versions/1d90f8a0efe1_update_description_columns_type.py
Outdated
Show resolved
Hide resolved
…_description_columns_type.py Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
@ogabrielluiz , I think everything is okay now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@ogabrielluiz , Do you know when this is going to be merged? |
…#3431) * fix: Problem in the description field when using the MariaDB or MySQL database. * fix: Problem in the description field when using the MariaDB or MySQL database. * fix: Add the migration script to update description columns type. * [autofix.ci] apply automated fixes * Update src/backend/base/langflow/alembic/versions/1d90f8a0efe1_update_description_columns_type.py Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> --------- Co-authored-by: Marcelo Nunes <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
@ogabrielluiz ogabrielluiz `024-09-04 16:27:44,552 - migration.py[line:218] - INFO: Will assume non-transactional DDL.
|
And I fix the code, I think it works.
|
I fix it in #3678 |
The columns listed below may also need to be changed from VARCHAR(255) to TEXT.
|
Hi @sa411022, how are you? Do you push a PR about this? |
This pull request addresses an issue where the 'description' fields, defined as str in the SQLModel model, were being created as varchar(255) columns in MariaDB and MySQL databases. This behavior was inconsistent with the expected text data type for these fields.
Changes:
Reasoning:
Below is the print with the error generated:
I think it is related to this Issuer that was closed: #1890
log_error_mysql_maria.log