Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions modules/tool/packages/dbops/children/oracle/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ export async function main({
await sql.close();
await pool.close();
return {
result: {
rows: result?.rows ?? [],
metaData: result?.metaData ?? []
}
result: JSON.parse(JSON.stringify(result))
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

Using JSON.parse(JSON.stringify()) is inefficient and can cause issues. This approach:

  1. Has poor performance due to double serialization overhead
  2. Will throw an error if result is undefined (when sql.execute() returns undefined for some queries)
  3. Loses non-serializable properties like Buffers, Dates (converted to strings), and circular references
  4. Is inconsistent with other database implementations (MySQL, PostgreSQL, SQL Server, ClickHouse) which all return the result directly

The reverted code with explicit structure and null coalescing (rows ?? [], metaData ?? []) was safer as it handled edge cases where the Oracle driver might return undefined or partial results.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

This implementation is inconsistent with other database operations in the codebase. MySQL, PostgreSQL, SQL Server, and ClickHouse implementations all return the result directly without JSON serialization. Consider aligning the Oracle implementation with these patterns for consistency and maintainability.

Suggested change
result: JSON.parse(JSON.stringify(result))
result

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The JSON.parse(JSON.stringify()) pattern introduces significant performance overhead, especially for large query results. This double serialization process is unnecessary and inefficient compared to either returning the result object directly or constructing a simple object with the needed properties.

Suggested change
result: JSON.parse(JSON.stringify(result))
result

Copilot uses AI. Check for mistakes.
};
} catch (error: unknown) {
if (error instanceof Error) {
Expand Down