Code Monkey home page Code Monkey logo

Comments (20)

true-hb avatar true-hb commented on June 11, 2024 1

I would put this in the resources\oradewrc-schema.json:

  "source.pattern": {
    "description": "Naming patterns for the sources of different object types",
    "type": "object",
    "properties": {
      "package-spec":  {
        "default": "./src/{schema-name}/PACKAGES/{object-name}.sql",
        "description": "Naming pattern for package specifications",
        "type": "string"
      },
      "package-body":  {
        "default": "./src/{schema-name}/PACKAGE_BODIES/{object-name}.sql",
        "description": "Naming pattern for package bodies",
        "type": "string"
      },
      "trigger":  {
        "default": "./src/{schema-name}/TRIGGERS/{object-name}.sql",
        "description": "Naming pattern for triggers",
        "type": "string"
      },
      "type-spec":  {
        "default": "./src/{schema-name}/TYPES/{object-name}.sql",
        "description": "Naming pattern for type specifications",
        "type": "string"
      },
      "type-body":  {
        "default": "./src/{schema-name}/TYPE_BODIES/{object-name}.sql",
        "description": "Naming pattern for type bodies",
        "type": "string"
      },
      "view":  {
        "default": "./src/{schema-name}/VIEWS/{object-name}.sql",
        "description": "Naming pattern for views",
        "type": "string"
      },
      "function":  {
        "default": "./src/{schema-name}/FUNCTIONS/{object-name}.sql",
        "description": "Naming pattern for functions",
        "type": "string"
      },
      "procedure":  {
        "default": "./src/{schema-name}/PROCEDURES/{object-name}.sql",
        "description": "Naming pattern for procedures",
        "type": "string"
      }
    }
  }

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

Amendment: Even when I select an invalid statement and use "Run Selected Statement" by right mouse button, the errors are shown in problems window.
But when I select the whole package source using Ctrl+a and subsequently use "Run Selected Statement", the errors are not shown.

from oradew-vscode.

mickeypearce avatar mickeypearce commented on June 11, 2024

Hi, can you please post printscreen or terminal output after compiling?

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

this is terminal output (partly in german, sorry):

Executing task: C:\Program Files\nodejs\node.exe c:\Users\Truetken-H.vscode\extensions\mp.oradew-vscode-0.3.11\node_modules\gulp\bin\gulp.js --cwd c:\cvs\resusDB --gulpfile c:\Users\Truetken-H.vscode\extensions\mp.oradew-vscode-0.3.11\out\gulpfile.js --color true --silent true compile --env RES_TEST --file c:\cvs\resusDB\packages\RD_POI-body.SQL <

Success => RESUS@RES_TEST $c:\cvs\resusDB\packages\RD_POI-body.SQL

Das Terminal wird von Aufgaben wiederverwendet, drücken Sie zum Schließen eine beliebige Taste.

from oradew-vscode.

mickeypearce avatar mickeypearce commented on June 11, 2024

What kind of error do you expect?
Can you send me a peace of code so I can reproduce?
Thanks a lot.

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

Take this one:

CREATE OR REPLACE PACKAGE test_oradew AS
	FUNCTION incorrect (n NUMBER)
	RETURN VARCHAR22;
END test_oradew;
/

The answer is


> Executing task: C:\Program Files\nodejs\node.exe c:\Users\Truetken-H\.vscode\extensions\mp.oradew-vscode-0.3.11\node_modules\gulp\bin\gulp.js --cwd c:\cvs\resusDB --gulpfile c:\Users\Truetken-H\.vscode\extensions\mp.oradew-vscode-0.3.11\out\gulpfile.js --color true --silent true compile --env RES_TEST --file c:\cvs\resusDB\packages\test_oradew.sql <

Success => RESUS@RES_TEST $c:\cvs\resusDB\packages\test_oradew.sql

Das Terminal wird von Aufgaben wiederverwendet, drücken Sie zum Schließen eine beliebige Taste.

When I execute the following statement:

select name,type,line,position,text,attribute,message_number from user_errors
order by 1,2,3

I get this:

NAME         TYPE     LINE POSITION TEXT                                     ATTRIBUTE MESSAGE_NUMBER
------------ -------- ---- -------- ---------------------------------------- --------- --------------
TEST_ORADEW  PACKAGE     2        2 PL/SQL: Declaration ignored              ERROR                  0
TEST_ORADEW  PACKAGE     3        9 PLS-00201: identifier 'VARCHAR22' must   ERROR                201
                                    be declared

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

btw.: I'm working with Windows 10, the database ist Oracle 11g and sqlcl in Version 19.2.0.

May be interesting: When I work directly with sqlcl, I get
java.io.UnsupportedEncodingException: WE8MSWIN1252
for any Select-Statement until I do the following:
set encoding ibm852

from oradew-vscode.

mickeypearce avatar mickeypearce commented on June 11, 2024

I think the problem is that you have to put your package into correct file structure, as Oradew gets from file structure object information to then query from errors:

./src/RESUS/PACKAGES/TEST_ORADEW.sql would be a correct one in your case.

If you run it outside of SRC structure, you can run it with "Run Current File as Script" (F5) and see errors from SqlPlus, but they are not parsed as Problems...

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

Yeah, this works. But I'm not satisfied, because we have another directory structure in git.

We use the following structure:

  • ./packages/{object-name}-spec.sql für Package-Specifications
  • ./packages/{object-name}-body.sql für Package-Bodies
  • ./trigger/{object-name}-trigger.sql für Triggers
  • ./views/{object-name}-view.sql für Views

Currently we don't have any more objecttypes in git.
We use just one database-schema, so we don't need the schema-name.
We don't use the schema name in our database-scripts, so the syntax always is
CREATE OR REPLACE {object-type} {object-name} AS ...
instead of
CREATE OR REPLACE {object-type} "{schema-name}"."{object-name}" AS ...

Is it possible to define such a structure by configuration?

from oradew-vscode.

mickeypearce avatar mickeypearce commented on June 11, 2024

Hey, thanks for your feedback.

  1. If you have only one schema in your project, you can ommit schema directory from structure. It will work.
  2. Unnused directories (objecttypes) can be removed as well.
  3. Ommiting schema name in object code is also not a problem when compiling.
  4. Custom structure and object-file name is a problem right now. but something could be done to make it configurable as you suggest...

Any ideas on how to make this object-structure mapping configurable ?

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

you might add following to ensure that the object-name is part of the pattern:
"pattern" : "([\w_.-](\{schema-name\})?[\w_.-]/)+[\w_.-]\{object-name\}[\w_.-]"

from oradew-vscode.

mickeypearce avatar mickeypearce commented on June 11, 2024

Great suggestion!

Could we use regex to extract "schema-name", "object-type" and "object-name" from file path based on configured pattern?

We have this function that extracts object info from path:

utils.getDBObjectFromPath = path => {

that should be modified to use "source.patterns".

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

Oooh, sorry, I'm no javascript geek.
But I will try ;-)

// something like this may be used to get the object-typ to a filename
let mapObjectTypeToPattern = {
    "PACKAGE" : source.pattern.package-spec.pattern,
    "PACKAGE BODY" : source.pattern.package-body.pattern,
    "TRIGGER" : source.pattern.trigger.pattern,
    "TYPE" : source.pattern.type-spec.pattern,
    "TYPE BODY" : source.pattern.type-body.pattern,
    "VIEW" : source.pattern.view.pattern,
    "FUNCTION" : source.pattern.function.pattern,
    "PROCEDURE" : source.pattern.procedure.pattern
};
const invertPattern = obj => val => {
    for (let key in obj) {
        if (obj[key].match(val) )
            return key;
    }
};

From now it get's really difficult. Maybe you can use something like the split-function for patterns.
I will try to look for something like that later ...

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

I got an idea. First you switch the pattern ton another pattern:
altPattern = new RegExp ('^(' + replace (source.pattern, '{object-name}', '|') + ')$';)
So, if source.pattern is "package/{object-name}-spec.sql", altPattern should be "^(package/|-spec.sql$)"
Now you can do somehing like this:
objectName = fileName.replace (altPattern);

Ok?

from oradew-vscode.

mickeypearce avatar mickeypearce commented on June 11, 2024

Could we just add regex to "source.pattern" and then use this pattern to extract data from filepath.

For example:
We have filepath: "./src/RESUS/PACKAGES/TEST_ORADEW.sql", is it possible to write a regex with groups that would extract "RESUS", "PACKAGES" and "TEST_ORADEW"?

Thanks for your help, @true-hb.

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

Sorry, I'm not sure if not know what you mean.
If you have
filepath="./src/RESUS/PACKAGES/TEST_ORADEW.sql";
with

var regex=new RegExp('\w+');
var match=regex.exec (filepath);

you should get an array with ["src","RESUS","PACKAGES","TEST_ORADEW","sql"]
Is that what you need?

Sorry again, my javascript is not so good ;-)

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

I got an idea. First you switch the pattern ton another pattern:
altPattern = new RegExp ('^(' + replace (source.pattern, '{object-name}', '|') + ')$';)
So, if source.pattern is "package/{object-name}-spec.sql", altPattern should be "^(package/|-spec.sql$)"
Now you can do somehing like this:
objectName = fileName.replace (altPattern);

Ok?

This does not work with a path lile "./src/{schema-name}/PACKAGES/{object-name}.sql".
The path has to be "src/{schema-name}/PACKAGES/{object-name}.sql" (without ./ at the beginning).

from oradew-vscode.

mickeypearce avatar mickeypearce commented on June 11, 2024

What about using globs to match object-type from path?

Convert all patterns to:
"./src/*/FUNCTIONS/*.sql"
"./src/*/PROCEDURES/*.sql"
....
etc. and then try to match those with actual file path:
"./src/RESUS/FUNCTIONS/my-object.sql" for example.

When a match is found we get the object-type.

Then extract object-name etc as you suggest....

from oradew-vscode.

true-hb avatar true-hb commented on June 11, 2024

this looks like a good idea to me!

from oradew-vscode.

mickeypearce avatar mickeypearce commented on June 11, 2024

@true-hb , I released 0.3.12 with "source.pattern" configuration.

from oradew-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.