Add type_refs API guidance and db:query warning
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,18 @@ class Query_Command extends Command
|
||||
$is_select = preg_match('/^\s*(SELECT|SHOW|EXPLAIN|DESCRIBE|DESC)\b/i', $query);
|
||||
$is_data_modification = preg_match('/^\s*(INSERT|UPDATE|DELETE|REPLACE|TRUNCATE)\b/i', $query);
|
||||
|
||||
// Warn about querying _type_refs table directly
|
||||
if (stripos($query, 'select') !== false && stripos($query, '_type_refs') !== false) {
|
||||
$this->warn(
|
||||
"[WARNING] Querying _type_refs table directly is discouraged.\n" .
|
||||
" Type ref IDs are auto-generated and not predictable across environments.\n" .
|
||||
" Use the Type_Ref_Registry API instead:\n" .
|
||||
" \$id = Type_Ref_Registry::class_to_id('Model_Name');\n" .
|
||||
" This applies especially to migrations - see rsx/resource/migrations/CLAUDE.md"
|
||||
);
|
||||
$this->newLine();
|
||||
}
|
||||
|
||||
// Check if this is a SELECT query that needs modification
|
||||
$needs_limit_injection = preg_match('/^\s*SELECT\b/i', $query) && preg_match('/\bFROM\b/i', $query);
|
||||
$has_calc_found_rows = preg_match('/\bSQL_CALC_FOUND_ROWS\b/i', $query);
|
||||
|
||||
Reference in New Issue
Block a user