mirror of https://github.com/AMT-Cheif/drift.git
Don't remap tables from sql -> moor -> sql
This commit is contained in:
parent
7ab71f7558
commit
da9ca61e0c
|
@ -10,7 +10,7 @@ Currently, we support
|
|||
- navigation for references in sql queries
|
||||
|
||||
## Setup
|
||||
To debug this plugin, you'll need to perform these steps once. It is assumed that you
|
||||
To use this plugin, you'll need to perform these steps once. It is assumed that you
|
||||
have already cloned the `moor` repository.
|
||||
|
||||
1. Make sure you run version `3.5.0` or later of the Dart extension in VS Code.
|
||||
|
@ -23,7 +23,10 @@ have already cloned the `moor` repository.
|
|||
```
|
||||
3. Uncomment the plugin lines in `analysis_options.yaml`
|
||||
|
||||
## Running
|
||||
## Debugging
|
||||
Note: If you only want to _use_ the plugin and don't care about debugging it, follow the step
|
||||
from the [user documentation](https://moor.simonbinder.eu/docs/using-sql/sql_ide/).
|
||||
|
||||
After you completed the setup, these steps will open an editor instance that runs the plugin.
|
||||
1. chdir into `moor_generator` and run `lib/plugin.dart`. You can run that file from an IDE if
|
||||
you need debugging capabilities, but starting it from the command line is fine. Keep that
|
||||
|
|
|
@ -121,9 +121,11 @@ class CreateTableReader {
|
|||
overrideDontWriteConstraints: true,
|
||||
);
|
||||
|
||||
return specifiedTable
|
||||
..declaration =
|
||||
TableDeclaration(specifiedTable, step.file, null, table.definition);
|
||||
final declaration = TableDeclaration(
|
||||
specifiedTable, step.file, null, table.definition,
|
||||
tableFromSqlParser: table);
|
||||
|
||||
return specifiedTable..declaration = declaration;
|
||||
}
|
||||
|
||||
UsedTypeConverter _readTypeConverter(MappedBy mapper) {
|
||||
|
|
|
@ -39,8 +39,10 @@ class ColumnDeclaration extends BaseDeclaration {
|
|||
/// a referenced table was declared and provide navigation hints.
|
||||
class TableDeclaration extends BaseDeclaration {
|
||||
final SpecifiedTable table;
|
||||
final Table tableFromSqlParser;
|
||||
|
||||
TableDeclaration(this.table, FoundFile declarationFile,
|
||||
Element dartDeclaration, AstNode moorDeclaration)
|
||||
Element dartDeclaration, AstNode moorDeclaration,
|
||||
{this.tableFromSqlParser})
|
||||
: super(declarationFile, dartDeclaration, moorDeclaration);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ class TypeMapper {
|
|||
/// Convert a [SpecifiedTable] from moor into something that can be understood
|
||||
/// by the sqlparser library.
|
||||
Table extractStructure(SpecifiedTable table) {
|
||||
final existingTable = table.declaration?.tableFromSqlParser;
|
||||
if (existingTable != null) {
|
||||
return existingTable;
|
||||
}
|
||||
|
||||
final columns = <TableColumn>[];
|
||||
for (final specified in table.columns) {
|
||||
final hint = specified.typeConverter != null
|
||||
|
|
Loading…
Reference in New Issue