{"record":{"id":"b6bc5c33ac10dcff","repo":"laravel/framework","slug":"using-three-part-references-is-not-supported-you","errorCode":null,"errorMessage":"Using three-part references is not supported, you may use `Schema::connection('{$segments[0]}')` instead.","messagePattern":"Using three-part references is not supported, you may use `Schema::connection\\('(.+?)'\\)` instead\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Schema/Builder.php","lineNumber":757,"sourceCode":"    {\n        return $this->getCurrentSchemaListing()[0] ?? null;\n    }\n\n    /**\n     * Parse the given database object reference and extract the schema and table.\n     *\n     * @param  string  $reference\n     * @param  string|bool|null  $withDefaultSchema\n     * @return array{string|null, string}\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function parseSchemaAndTable($reference, $withDefaultSchema = null)\n    {\n        $segments = explode('.', $reference);\n\n        if (count($segments) > 2) {\n            throw new InvalidArgumentException(\n                \"Using three-part references is not supported, you may use `Schema::connection('{$segments[0]}')` instead.\"\n            );\n        }\n\n        $table = $segments[1] ?? $segments[0];\n\n        $schema = match (true) {\n            isset($segments[1]) => $segments[0],\n            is_string($withDefaultSchema) => $withDefaultSchema,\n            $withDefaultSchema => $this->getCurrentSchemaName(),\n            default => null,\n        };\n\n        return [$schema, $table];\n    }\n\n    /**\n     * Get the database connection instance.","sourceCodeStart":739,"sourceCodeEnd":775,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Schema/Builder.php#L739-L775","documentation":"Builder::parseSchemaAndTable() splits the reference on '.' and rejects anything with more than two segments - i.e. a three-part (catalog.schema.table) reference - with an InvalidArgumentException. Laravel's schema introspection is scoped to a single connection; cross-database references must go through a separate connection rather than a dotted string. The error message itself names the suggested fix using $segments[0].","triggerScenarios":"Passing 'mydb.public.users' (or any reference with two dots) to any Builder method that parses schema/table: getColumns, getColumnListing, getColumnType, hasColumn, getIndexes, getForeignKeys, etc. Also triggered indirectly when a migration or model hands such a string to Schema::hasTable().","commonSituations":"Copying a SQL Server or MySQL cross-database query pattern into Laravel schema calls; reading table names from a config that includes the catalog; MySQL users who prefix with database name out of habit; refactoring a single-DB app into multi-DB and forgetting to switch connections.","solutions":["Use Schema::connection($catalog)->... with the two-part (schema.table) or one-part (table) reference instead.","Strip the leading catalog segment from your reference string before passing it to a Schema method.","Normalise table names in configuration so they never carry the database/catalog prefix."],"exampleFix":"// before - three-part reference throws\nSchema::hasTable('inventory.public.products');\n\n// after - switch connection and drop the catalog segment\nSchema::connection('inventory')->hasTable('public.products');\n// or, on the default schema:\nSchema::connection('inventory')->hasTable('products');","handlingStrategy":"validation","validationCode":"if (substr_count($reference, '.') > 1) {\n    throw new \\InvalidArgumentException(\n        \"Reference '{$reference}' has more than 2 segments; use Schema::connection() for cross-database access.\"\n    );\n}\nSchema::hasTable($reference);","typeGuard":"function isParsableTableReference(string $reference): bool\n{\n    return substr_count($reference, '.') <= 1;\n}","tryCatchPattern":"try {\n    Schema::hasTable($reference);\n} catch (\\InvalidArgumentException $e) {\n    if (str_contains($e->getMessage(), 'three-part references')) {\n        [$connection, $rest] = explode('.', $reference, 2);\n        return Schema::connection($connection)->hasTable($rest);\n    }\n    throw $e;\n}","preventionTips":["Keep table identifiers free of the catalog/database prefix in config and migrations.","Use Schema::connection($catalog) for cross-database access rather than dotted strings.","Validate user-supplied table references against substr_count($ref, '.') <= 1 at the boundary."],"tags":["schema","multi-database","invalid-argument","connection"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}