Closed rifay-next99 closed 6 months ago
This should be a bug in code_builder
(on Windows), the string for this parameter should be one line, containing the \n
translation symbol. But it wraps automatically in your code, it could also be a problem with the dart_style package, I don't have a windows device, I'm not sure. But it is normal in Linux and macOS.
I've tried also in Ubuntu (WSL) and gives the same error
@AndryHTC @rifay-next99 Can you give me a minimal schema.prisma that causes this error? I can't reproduce it at the moment.
@AndryHTC @rifay-next99 Can you give me a minimal schema.prisma that causes this error? I can't reproduce it at the moment.
It's the same schema I sent you for the other issue (maybe the same issue as well) https://github.com/medz/prisma-dart/issues/340. I removed the schema from the issue after you closed it, but if you need it again I'll do it
不,我需要一个更加小型的 schema,我始终无法复现你们提示的这两个问题。
bruh
generator client {
provider = "dart run orm"
output = "../lib/src/prisma_client/"
previewFeatures = ["fullTextSearch", "fullTextIndex"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}
model Soggetto {
uuid String @id @default(uuid())
ragioneSociale String
iban String?
negozioPreferitoUuid String?
codiceFiscale String? @unique
note String?
}
> npx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Building package executable... (4.8s)
Built orm:orm.
Error:
Could not format because the source could not be parsed:
line 71, column 59 of .: Unterminated string literal.
╷
71 │ final engine = _i4.BinaryEngine(schema: 'generator client {
│ ^
╵
line 75, column 3 of .: Expected to find ')'.
╷
75 │ \n}
│ ^
╵
line 90, column 34 of .: Unterminated string literal.
╷
90 │ \n}', datasources: datasources, );
│ ^
╵
line 71, column 41 of .: Expected to find ';'.
╷
71 │ final engine = _i4.BinaryEngine(schema: 'generator client {
│ ^^^^^^^^^^^^^^^^^^^
╵
line 72, column 1 of .: Expected an identifier.
╷
72 │ \n provider = "dart run orm"
│ ^
╵
line 72, column 1 of .: Expected to find ';'.
╷
72 │ \n provider = "dart run orm"
│ ^
╵
line 72, column 23 of .: Expected to find ';'.
╷
72 │ \n provider = "dart run orm"
│ ^^^^^^^^^^^^^^
╵
line 73, column 1 of .: Expected an identifier.
╷
73 │ \n output = "../lib/src/prisma_client/"
│ ^
╵
line 73, column 1 of .: Expected to find ';'.
╷
73 │ \n output = "../lib/src/prisma_client/"
│ ^
╵
line 73, column 23 of .: Expected to find ';'.
╷
73 │ \n output = "../lib/src/prisma_client/"
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
(63 more errors...)
OK, I'll try it!
@AndryHTC Still not successful
https://github.com/medz/prisma-dart/commit/2afc7ad2a4ea34b42f73062f3d6a29c697761e54
Maybe, it only appears on Windows?
Maybe, it only appears on Windows?
It could.
What could I do to help you in this matter?
I encountered the same error days ago and i fixed it with Flutter clean then Flutter pub get
Unfortunately, I did not successfully reproduce this error.
I've cleaned everything possible, and still do not work.
Prisma client version? Node version? Anything else?
@kidusdev were you on Windows?
@medz I can now confirm that in Mac OS I don't have this problem. Seems to be Windows-specific... But even in that case it's still an important bug to fix
@AndryHTC Unfortunately, I don't have a Windows device. In addition, I observed that the error was usually wrongly in the source code. Maybe it's a bug in the code_builder package. I need to take time to borrow a Windows device from a friend to continue to find the reason.
Virtualized Windows on Mac OS is pretty easy to set up.
I hope you can solve this soon, can't wait to use Dart Orm 4. Thank you @medz
Sorry, Windows is too complicated. I didn’t even install the Dart environment successfully😫
The code about this bug is at https://github.com/medz/prisma-dart/blob/main/bin/src/generate_client.dart#L88 Can developers whose main device is Windows help me fix it?
Not successfully reproduce on my Windows 11.
orm : ^4.0.2
prisma : 5.8.1
Node.js : v16.20.0
Dart SDK version: 3.3.2 (stable) (Tue Mar 19 20:44:48 2024 +0000) on "windows_x64"
Just for reference with the versions you mentioned @NeroSong
This is so confusing 🤔
@AndryHTC https://pub.dev/packages/orm/versions/4.0.1-issue.344 The error message seems to come from Dart formatter, and I have provided a special version for this issue. It does not format dart code, but constructs the source code and outputs it as is. Would you like to try it? If there is no problem, maybe we can locate the bug causing this problem.
It's also possible that the literalString
function (which comes from code_builder
) mistakenly wraps \r\n
instead of translating and outputting the newline symbol. We now need this special build of 4.0.1-issue.344
to confirm it.
I always feel that it is because code_builder
's handling of newlines is too crude, leading to the forgetting of some use cases.
@AndryHTC https://pub.dev/packages/orm/versions/4.0.1-issue.344 The error message seems to come from Dart formatter, and I have provided a special version for this issue. It does not format dart code, but constructs the source code and outputs it as is. Would you like to try it? If there is no problem, maybe we can locate the bug causing this problem.
@medz it worked! Is it a definitive fix or have you still to tweak some details?
The client is generated with Dart errors BTW.
final engine = _i4.BinaryEngine(schema: 'generator client {
\n provider = "dart run orm"
\n output = "../lib/src/prisma_client/"
\n previewFeatures = ["fullTextSearch", "fullTextIndex"]
\n}
\n
\ndatasource db {
\n provider = "mysql"
\n url = env("DATABASE_URL")
\n relationMode = "prisma"
\n}
\n
\nmodel Soggetto {
\n uuid String @id @default(uuid())
\n ragioneSociale String
\n iban String?
\n negozioPreferitoUuid String?
\n codiceFiscale String? @unique
\n note String?
\n}
\n', datasources: datasources, );
Just by adding the triple quotes, the linter goes quiet.
final engine = _i4.BinaryEngine(schema: '''generator client {
\n provider = "dart run orm"
\n output = "../lib/src/prisma_client/"
\n previewFeatures = ["fullTextSearch", "fullTextIndex"]
\n}
\n
\ndatasource db {
\n provider = "mysql"
\n url = env("DATABASE_URL")
\n relationMode = "prisma"
\n}
\n
\nmodel Soggetto {
\n uuid String @id @default(uuid())
\n ragioneSociale String
\n iban String?
\n negozioPreferitoUuid String?
\n codiceFiscale String? @unique
\n note String?
\n}
\n''', datasources: datasources, );
I don't know if the \n
are going to cause issues to the engine
Reproduce it when I change my VSCode EOL setting to CRLF:
And set it back to LF is fine.
Looks @medz find the final problem, bingo 😄👍
fixed in v4.0.3
version
PS D:\Rifay\dart_frog\fitish_bend-Dart_frog> npx prisma generate Environment variables loaded from .env Prisma schema loaded from prisma\schema.prisma Building package executable... (4.5s) Built orm:orm. Error: Could not format because the source could not be parsed:
line 376, column 76 of .: Unterminated string literal. ╷ 376 │ final engine = _i4.BinaryEngine(schema: '// This is your Prisma schema file, │ ^ ╵ line 487, column 33 of .: Unterminated string literal. ╷ 487 │ \n', datasources: datasources, ); │ ^ ╵ line 491, column 51 of .: Expected to find ')'. ╷ 491 │ return createClientWithTransaction(transaction); } │ ^ ╵ line 376, column 41 of .: Expected to find ';'. ╷ 376 │ final engine = _i4.BinaryEngine(schema: '// This is your Prisma schema file, │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ╵ line 377, column 1 of .: Expected an identifier. ╷ 377 │ \n// learn more about it in the docs: https://pris.ly/d/prisma-schema │ ^ ╵ line 377, column 1 of .: Expected to find ';'. ╷ 377 │ \n// learn more about it in the docs: https://pris.ly/d/prisma-schema │ ^ ╵ line 377, column 2 of .: Expected to find ';'. ╷ 377 │ \n// learn more about it in the docs: https://pris.ly/d/prisma-schema │ ^ ╵ line 378, column 1 of .: Expected an identifier. ╷ 378 │ \n │ ^ ╵ line 378, column 1 of .: Expected to find ';'. ╷ 378 │ \n │ ^ ╵ line 378, column 2 of .: Expected to find ';'. ╷ 378 │ \n │ ^ ╵ (404 more errors...)