add mysql backend support#393
Conversation
Bl3f
left a comment
There was a problem hiding this comment.
Look almost good to me thank you so much. Can you as well add an integration test for MySQL like the other providers in cli/tests/nao_core/commands/sync/integration folder?
| @@ -0,0 +1,20 @@ | |||
| services: | |||
There was a problem hiding this comment.
instead of creating this, the best would be to merge into a docker-compose.test.yml every database that can be embed in a Docker component, so we don't finish with an endless list of docker-compose files.
|
@teoria Could you share any update on this pr? I also need MySQL support! |
I needed to add a new dependency to the Dockerfile. |
|
Signed-off-by: Rodrigo Carneiro <teoria@gmail.com>
…to feat/211-add_mysql_support
🧹 Preview RemovedThe preview deployment for this PR has been cleaned up. |
There was a problem hiding this comment.
2 issues found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="Dockerfile">
<violation number="1" location="Dockerfile:72">
P1: MySQL/MariaDB client library is only installed in builder stage, so compiled MySQL Python backend can fail at runtime due to missing shared libs in final image.</violation>
</file>
<file name="cli/tests/nao_core/commands/sync/integration/test_mysql.py">
<violation number="1" location="cli/tests/nao_core/commands/sync/integration/test_mysql.py:68">
P2: MySQL integration fixture suppresses SQL seed failures, allowing setup to continue with a potentially incomplete database.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| gcc \ | ||
| unixodbc-dev \ | ||
| pkg-config \ | ||
| libmariadb-dev \ |
There was a problem hiding this comment.
P1: MySQL/MariaDB client library is only installed in builder stage, so compiled MySQL Python backend can fail at runtime due to missing shared libs in final image.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Dockerfile, line 72:
<comment>MySQL/MariaDB client library is only installed in builder stage, so compiled MySQL Python backend can fail at runtime due to missing shared libs in final image.</comment>
<file context>
@@ -65,9 +65,13 @@ WORKDIR /app
+ gcc \
unixodbc-dev \
+ pkg-config \
+ libmariadb-dev \
&& rm -rf /var/lib/apt/lists/*
-
</file context>
| if statement: | ||
| try: | ||
| conn.raw_sql(statement).fetchall() | ||
| except Exception: |
There was a problem hiding this comment.
P2: MySQL integration fixture suppresses SQL seed failures, allowing setup to continue with a potentially incomplete database.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At cli/tests/nao_core/commands/sync/integration/test_mysql.py, line 68:
<comment>MySQL integration fixture suppresses SQL seed failures, allowing setup to continue with a potentially incomplete database.</comment>
<file context>
@@ -0,0 +1,144 @@
+ if statement:
+ try:
+ conn.raw_sql(statement).fetchall()
+ except Exception:
+ pass
+
</file context>
🚀 Preview Deployment
Preview will be automatically removed when this PR is closed. |
There was a problem hiding this comment.
2 issues found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="Dockerfile">
<violation number="1" location="Dockerfile:72">
P1: MySQL client native library is compiled in the builder but missing from runtime image, which can cause MySQL backend import/linker failures at runtime.</violation>
</file>
<file name="cli/nao_core/config/databases/mysql.py">
<violation number="1" location="cli/nao_core/config/databases/mysql.py:20">
P2: MySQL identifier quoting is unsafe because `_quote()` does not escape embedded backticks before interpolating identifiers into raw SQL.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| gcc \ | ||
| unixodbc-dev \ | ||
| pkg-config \ | ||
| libmariadb-dev \ |
There was a problem hiding this comment.
P1: MySQL client native library is compiled in the builder but missing from runtime image, which can cause MySQL backend import/linker failures at runtime.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Dockerfile, line 72:
<comment>MySQL client native library is compiled in the builder but missing from runtime image, which can cause MySQL backend import/linker failures at runtime.</comment>
<file context>
@@ -65,9 +65,13 @@ WORKDIR /app
+ gcc \
unixodbc-dev \
+ pkg-config \
+ libmariadb-dev \
&& rm -rf /var/lib/apt/lists/*
-
</file context>
| """MySQL context with information_schema description discovery.""" | ||
|
|
||
| def _quote(self, name: str) -> str: | ||
| return f"`{name}`" |
There was a problem hiding this comment.
P2: MySQL identifier quoting is unsafe because _quote() does not escape embedded backticks before interpolating identifiers into raw SQL.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At cli/nao_core/config/databases/mysql.py, line 20:
<comment>MySQL identifier quoting is unsafe because `_quote()` does not escape embedded backticks before interpolating identifiers into raw SQL.</comment>
<file context>
@@ -16,6 +16,9 @@
"""MySQL context with information_schema description discovery."""
+ def _quote(self, name: str) -> str:
+ return f"`{name}`"
+
def description(self) -> str | None:
</file context>
| return f"`{name}`" | |
| return f"`{name.replace('`', '``')}`" |
#211
add mysql backend support