Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion libs/driver-adapters/executor/src/demo-qc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ async function main(): Promise<void> {

datasource db {
provider = "sqlite"
url = "file:./db.sqlite"
}

model User {
Expand Down
1 change: 0 additions & 1 deletion libs/driver-adapters/executor/src/demo-se.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ async function main(): Promise<void> {

datasource db {
provider = "sqlite"
url = "${url}"
}

model User {
Expand Down
12 changes: 1 addition & 11 deletions libs/test-setup/src/test_api_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,11 @@ impl TestApiArgs {

pub fn datasource_block<'a>(
&'a self,
url: &'a str,
params: &'a [(&'a str, &'a str)],
preview_features: &'static [&'static str],
) -> DatasourceBlock<'a> {
DatasourceBlock {
provider: self.db.provider,
url,
params,
preview_features,
}
Expand All @@ -201,7 +199,7 @@ impl TestApiArgs {
self.db.provider
}

pub fn shadow_database_url(&self) -> Option<&'static str> {
pub fn shadow_database_url(&self) -> Option<&str> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

can also now be reverted but also doesn't hurt to leave it, there's no need for it to be static

self.db.shadow_database_url.as_deref()
}

Expand All @@ -216,16 +214,10 @@ impl TestApiArgs {

pub struct DatasourceBlock<'a> {
provider: &'a str,
url: &'a str,
params: &'a [(&'a str, &'a str)],
preview_features: &'static [&'static str],
}

impl DatasourceBlock<'_> {
pub fn url(&self) -> &str {
self.url
}
}
fn generator_block(preview_features: &'static [&'static str]) -> String {
let preview_features: Vec<String> = preview_features.iter().map(|pf| format!(r#""{pf}""#)).collect();

Expand All @@ -251,8 +243,6 @@ impl Display for DatasourceBlock<'_> {

f.write_str("datasource db {\n provider = \"")?;
f.write_str(self.provider)?;
f.write_str("\"\n url = \"")?;
f.write_str(self.url)?;
f.write_str("\"\n")?;

for (param_name, param_value) in self.params {
Expand Down
1 change: 0 additions & 1 deletion prisma-fmt/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
datasource db {
provider = "postgresql"
url = env("MEOW")
}
9 changes: 3 additions & 6 deletions prisma-fmt/src/code_actions/multi_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,8 @@ pub(super) fn add_schema_to_schemas(
)
}
None => {
let has_properties = datasource.provider_defined() | datasource.url_defined()
|| datasource.direct_url_defined()
|| datasource.shadow_url_defined()
|| datasource.relation_mode_defined()
|| datasource.schemas_defined();
let has_properties =
datasource.provider_defined() || datasource.relation_mode_defined() || datasource.schemas_defined();

let formatted_attribute = super::format_block_property(
"schemas",
Expand All @@ -180,7 +177,7 @@ pub(super) fn add_schema_to_schemas(
datasource_content,
formatted_attribute,
true,
datasource.url_span,
datasource.provider_span,
)
}
};
Expand Down
26 changes: 3 additions & 23 deletions prisma-fmt/src/get_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ mod tests {
"datasource.prisma",
r#"datasource db {
provider = "postgresql"
url = "postgresql://example.com/db"
}"#,
),
];
Expand All @@ -203,33 +202,14 @@ mod tests {
});

let expected = expect![[
r#"{"config":{"generators":[{"name":"js","provider":{"fromEnvVar":null,"value":"prisma-client"},"output":null,"config":{},"binaryTargets":[],"previewFeatures":[],"sourceFilePath":"generator.prisma"}],"datasources":[{"name":"db","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":null,"value":"postgresql://example.com/db"},"schemas":[],"sourceFilePath":"datasource.prisma"}],"warnings":[]},"errors":[]}"#
r#"{"config":{"generators":[{"name":"js","provider":{"fromEnvVar":null,"value":"prisma-client"},"output":null,"config":{},"binaryTargets":[],"previewFeatures":[],"sourceFilePath":"generator.prisma"}],"datasources":[{"name":"db","provider":"postgresql","activeProvider":"postgresql","schemas":[],"sourceFilePath":"datasource.prisma"}],"warnings":[]},"errors":[]}"#
]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}

#[test]
fn get_config_env_var() {
let schema = r#"
datasource thedb {
provider = "postgresql"
url = env("IGNORED")
}
"#;

let request = json!({
"prismaSchema": schema,
});
let expected = expect![[
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"IGNORED","value":null},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[]}"#
]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}

#[test]
fn get_config_direct_url_should_error() {
fn get_config_urls_should_error() {
let schema = r#"
datasource thedb {
provider = "postgresql"
Expand All @@ -245,7 +225,7 @@ mod tests {
}
});
let expected = expect![[
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":null},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mThe datasource property `directUrl` is no longer supported in schema files. Move connection URLs to `prisma.config.ts`. See https://pris.ly/d/config-datasource\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:5\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 4 | \u001b[0m url = env(\"DBURL\")\n\u001b[1;94m 5 | \u001b[0m \u001b[1;91mdirectUrl = \"postgresql://example.com/direct\"\u001b[0m\n\u001b[1;94m | \u001b[0m\n"}]}"#
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mThe datasource property `url` is no longer supported in schema files. Move connection URLs for Migrate to `prisma.config.ts` and pass either `adapter` for a direct database connection or `accelerateUrl` for Accelerate to the `PrismaClient` constructor. See https://pris.ly/d/config-datasource and https://pris.ly/d/prisma7-client-config\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:4\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 3 | \u001b[0m provider = \"postgresql\"\n\u001b[1;94m 4 | \u001b[0m \u001b[1;91murl = env(\"DBURL\")\u001b[0m\n\u001b[1;94m | \u001b[0m\n"},{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mThe datasource property `directUrl` is no longer supported in schema files. Move connection URLs to `prisma.config.ts`. See https://pris.ly/d/config-datasource\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:5\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 4 | \u001b[0m url = env(\"DBURL\")\n\u001b[1;94m 5 | \u001b[0m \u001b[1;91mdirectUrl = \"postgresql://example.com/direct\"\u001b[0m\n\u001b[1;94m | \u001b[0m\n"}]}"#
]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
Expand Down
1 change: 0 additions & 1 deletion prisma-fmt/src/get_datamodel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ mod tests {

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
Expand Down
29 changes: 2 additions & 27 deletions prisma-fmt/src/get_dmmf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ mod tests {
}

#[test]
fn get_dmmf_missing_env_var() {
fn get_dmmf_single_file() {
let schema = r#"
datasource thedb {
provider = "postgresql"
url = env("NON_EXISTING_ENV_VAR_WE_COUNT_ON_IT_AT_LEAST")
}
"#;

Expand Down Expand Up @@ -190,28 +189,6 @@ mod tests {
expected.assert_eq(&prettified_response);
}

#[test]
fn get_dmmf_direct_url_direct_empty() {
let schema = r#"
datasource thedb {
provider = "postgresql"
url = env("DBURL")
directUrl = ""
}
"#;

let request = json!({
"prismaSchema": schema,
});

let expected = expect![[
r#"{"error_code":"P1012","message":"\u001b[1;91merror\u001b[0m: \u001b[1mThe datasource property `directUrl` is no longer supported in schema files. Move connection URLs to `prisma.config.ts`. See https://pris.ly/d/config-datasource\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:5\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 4 | \u001b[0m url = env(\"DBURL\")\n\u001b[1;94m 5 | \u001b[0m \u001b[1;91mdirectUrl = \"\"\u001b[0m\n\u001b[1;94m | \u001b[0m\n\nValidation Error Count: 1"}"#
]];

let response = get_dmmf(&request.to_string()).unwrap_err();
expected.assert_eq(&response);
}

#[test]
fn get_dmmf_multiple_files() {
let schema = vec![
Expand All @@ -220,7 +197,6 @@ mod tests {
r#"
datasource thedb {
provider = "postgresql"
url = env("DBURL")
}

model A {
Expand Down Expand Up @@ -6907,7 +6883,6 @@ mod tests {
let schema = r#"
datasource db {
provider = "sqlite"
url = "sqlite"
relationMode = "prisma"
referentialIntegrity = "foreignKeys"
}
Expand All @@ -6918,7 +6893,7 @@ mod tests {
});

let expected = expect![[
r#"{"error_code":"P1012","message":"\u001b[1;91merror\u001b[0m: \u001b[1mThe `referentialIntegrity` and `relationMode` attributes cannot be used together. Please use only `relationMode` instead.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:6\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 5 | \u001b[0m relationMode = \"prisma\"\n\u001b[1;94m 6 | \u001b[0m \u001b[1;91mreferentialIntegrity = \"foreignKeys\"\u001b[0m\n\u001b[1;94m | \u001b[0m\n\nValidation Error Count: 1"}"#
r#"{"error_code":"P1012","message":"\u001b[1;91merror\u001b[0m: \u001b[1mThe `referentialIntegrity` and `relationMode` attributes cannot be used together. Please use only `relationMode` instead.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:5\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 4 | \u001b[0m relationMode = \"prisma\"\n\u001b[1;94m 5 | \u001b[0m \u001b[1;91mreferentialIntegrity = \"foreignKeys\"\u001b[0m\n\u001b[1;94m | \u001b[0m\n\nValidation Error Count: 1"}"#
]];
let response = get_dmmf(&request.to_string()).unwrap_err();
expected.assert_eq(&response);
Expand Down
10 changes: 4 additions & 6 deletions prisma-fmt/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ mod tests {
let schema = indoc! {r#"
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

generator client {
Expand All @@ -119,8 +118,8 @@ mod tests {
[
{
"file_name": "schema.prisma",
"start": 146,
"end": 160,
"start": 113,
"end": 127,
"text": "Preview feature \"createMany\" is deprecated. The functionality can be used without specifying it as a preview feature.",
"is_warning": true
}
Expand All @@ -134,7 +133,6 @@ mod tests {
let schema1 = indoc! {r#"
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

generator client {
Expand All @@ -158,8 +156,8 @@ mod tests {
[
{
"file_name": "schema1.prisma",
"start": 146,
"end": 160,
"start": 113,
"end": 127,
"text": "Preview feature \"createMany\" is deprecated. The functionality can be used without specifying it as a preview feature.",
"is_warning": true
}
Expand Down
3 changes: 0 additions & 3 deletions prisma-fmt/src/merge_schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ mod tests {
r#"
datasource db {
provider = "postgresql"
url = env("DBURL")
}

model A {
Expand All @@ -71,7 +70,6 @@ mod tests {

datasource db {
provider = "postgresql"
url = env("DBURL")
}

model A {
Expand Down Expand Up @@ -102,7 +100,6 @@ mod tests {
r#"
datasource db {
provider = "postgresql"
url = env("DBURL")
}

model A {
Expand Down
15 changes: 0 additions & 15 deletions prisma-fmt/src/text_document_completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,27 +144,13 @@ fn push_ast_completions(ctx: CompletionContext<'_>, completion_list: &mut Comple
datasource::provider_completion(completion_list);
}

if !ds_has_prop(&ctx, "url") {
datasource::url_completion(completion_list);
}

if !ds_has_prop(&ctx, "relationMode") {
datasource::relation_mode_completion(completion_list);
}

ctx.connector().datasource_completions(ctx.config, completion_list);
}

ast::SchemaPosition::DataSource(
_source_id,
ast::SourcePosition::Property("url", ast::PropertyPosition::FunctionValue("env")),
) => datasource::url_env_db_completion(completion_list, "url", ctx),

ast::SchemaPosition::DataSource(_source_id, ast::SourcePosition::Property("url", _)) => {
datasource::url_env_completion(completion_list);
datasource::url_quotes_completion(completion_list);
}

position => ctx.connector().datamodel_completions(ctx.db, position, completion_list),
}
}
Expand All @@ -173,7 +159,6 @@ fn ds_has_prop(ctx: &CompletionContext<'_>, prop: &str) -> bool {
if let Some(ds) = ctx.datasource() {
match prop {
"relationMode" => ds.relation_mode_defined(),
"url" => ds.url_defined(),
"provider" => ds.provider_defined(),
_ => false,
}
Expand Down
Loading
Loading