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:
root
2025-12-28 07:00:55 +00:00
parent e1d4ea6592
commit 432d167dda

View File

@@ -46,6 +46,18 @@ class Query_Command extends Command
// Determine query type // Determine query type
$is_select = preg_match('/^\s*(SELECT|SHOW|EXPLAIN|DESCRIBE|DESC)\b/i', $query); $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); $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 // 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); $needs_limit_injection = preg_match('/^\s*SELECT\b/i', $query) && preg_match('/\bFROM\b/i', $query);