-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add default values for all attributes from cursor #3
Comments
Hi jgebal, we already thought about default values for the API. As you suggested, it would be very usefull for CREATE operations. For other operations like UPDATE or CREATE_OR_UPDATE would be "risky" to use default values. Instead of a cursor, we have the idea to take the default value from the table column directly, I think it's the simplest way ;-) Best regards |
Hi Jacek, I like your idea and as André mentioned we already thought about it - but not so deep. We wanted only to provide the table defaults - but additional custom defaults would be also great. I was thinking a little bit about your idea and I have the following comments/ideas: To be backward compatible I don't want to change the default create_row methods (I use it already in some projects and breaking backward compatibility would be generate much work - in my projects and maybe also in some unknown projects of other users). How about two new functions per generated API? (@aborngra what do you think?)
There is one problem: We save the API creation parameters in the API spec to be able to recreate the API without any given parameter, that is also the reason to have the parameter One comment about our method names: We were inspired by the CRUD acronym for Create, Read, Update and Delete - that is the reason to use create_row instead of insert_xxx or ins_xxx. And yes, there is room for improvements - thanks for all your suggestions and ideas :-) Best regards |
Hi Guys, Adding default values should not be breaking change I think as, currently whenever you call the insert API, you need to specify all attributes. Maybe the defautls/no defaults should be parameter of generation? We're thinking of a very specific use-case for table API's (as helpers for unit tests). Thanks |
Hi Jacek, are you constantly working? ;-) You are right: The defaults are NOT invalidating the API on table changes - and this is a nice thing - to be remembered to recreate the APIs when table changes occur. For that I (hopefully also André) don't want to change the existing create_row logic - not to have default values was a design decision at our project start. I like the idea to have two additional create_row methods like mentioned before. With this it is also clear, which method does what regarding the defaults. And yes, we need parameters for that - thats the reason for my question before: which should be the parameter type for the creation of the Suggestion:
Best regards |
Oh, I think it should be:
Regards |
I'm wondering it having 3 different API entry pints to create a row isn't over-compilcating stuff too much.
I think that cursor could be better than XML as not all developers find XML easy enough. |
Hi Jacek, the parameter based entry point was to be able to direct assign APEX page items. The row type based for cases you want to change only some columns because it saves you much code and the procedure is useful if you don't care about a return value. May be the procedure could be omitted and the column based could be parameterized? I have to change much APEX calls without the column based version. At the end the code is generated and you pick what you need. But I am open for new ideas... I can remember that André was also thinking about to have only row based functions. I have to discuss this with him. Regarding the names - do you have an editor with autocompletion? ;-) I find a clear long name better then a short one - but this is may be a personal preference. For users who only review the code the long name is definitely better. For a developer who works the whole day with the code a short name is better. Is the longer name really an issue? Also I miss the distinction between the defaults defined for the table columns and the custom defaults. Do you only want to have the custom defaults? What about Best regards |
Hmmm... |
From my side no problem, best time for me would be something around 20:00 CET in the evening the next days. @aborngra: what do you think? But you mentioned that you are currently traveling. So enjoy your time first and then we can have a chat. |
Hi Jacek, I discussed the open issues with André - as far as you agree with the following sum up wee don't need a chat. We will see how long this will take - it is a free time project. We will keep you updated and create a new branch for the changes, so that you will be able to test before the official release. Best regards (also from André) Table API Generator - Next StepsAfter some rethinking: All listed improvements should be backward compatible since we have more than 20 known and some unknown applications using the current functionality. For special use cases a developer can create a wrapper to set his personal defaults. New Functionality
<defaults
employee_id="employees_seq.nextval"
first_name="'Chuck'"
last_name="'Norris'"
email="substr(sys_guid(),1,25)"
phone_number="'123'"
hire_date="to_date('2017-05-27','YYYY-MM-DD')"
job_id="'FI_MGR'"
salary="123"
commission_pct="0.01"
manager_id="null"
department_id="null"
/>
Improvements
|
Hi @ogobrecht, If you will create a separate branch for new features I might be able to do some skeleton for CI/CD on Travis and prepare basic unit testing for generator. Regards |
Hi Jacek, hi André, here the current status from today: Done
Work In Progress
To Do
|
Hi Jacek, the new parameter The last missing feature is now "new method create_a_row with default parameters". Best regards |
Hi Jacek, hi André now we are roughly feature complete - it was a short weekend ;-) @jgebal: Please be so kind and do your first tests and let us know if you can live with current implementation of the column defaults. The two new helper functions to retrieve automatically the column_defaults are completely independent of the package and can be used as a base for own implementations and specific business needs. Best regards Done - see also README.md in branch 0.5
<defaults>
<item><col>LAST_NAME</col><val>'Atkinson'</val></item>
...
</defaults> -- usage of the helper om_tapigen.util_get_custom_col_defaults:
BEGIN
om_tapigen.compile_api (
p_table_name => 'EMPLOYEES',
p_reuse_existing_api_params => FALSE,
p_col_prefix_in_method_names => TRUE,
p_enable_insertion_of_rows => TRUE,
p_enable_update_of_rows => TRUE,
p_enable_deletion_of_rows => FALSE,
p_enable_generic_change_log => TRUE,
p_enable_dml_view => TRUE,
p_sequence_name => 'EMPLOYEES_SEQ',
p_api_name => 'EMPLOYEES_API',
p_enable_getter_and_setter => FALSE,
p_enable_proc_with_out_params => FALSE,
P_enable_parameter_prefixes => FALSE,
p_return_row_instead_of_pk => TRUE,
p_column_defaults => om_tapigen.util_get_custom_col_defaults ('EMPLOYEES'));
END;
/
-- inspect the result of the helper
SELECT XMLSERIALIZE (
DOCUMENT OM_TAPIGEN.UTIL_GET_CUSTOM_COL_DEFAULTS (
P_TABLE_NAME => 'CAT_FEE_TYPES')
INDENT)
FROM DUAL; Remaining ToDo's
|
Hi @ogobrecht. Awesome progress in a short period of time. I really appreciate. I can help with implementation of some unit tests. The best way to start is to come up with requirements in form of small examples and turn those individual examples into tests. |
Hi Jacek, welcome to the club - the API generator is also a free time project of André and me :-) It takes as long as it takes - no expectations from our side. We have also much to do with the documentation, the SQL Developer integration, the tests with utPLSQL and so on... I had to fix today the pk column handling in the new method create_a_row - I was too concentrated to solve the issue with the parameter handling for the column defaults that I totally forgot the pk column handling: The pk column parameter defaults now to NULL since the sequence is handled by the create_row method or a trigger or in 12c automatically with the identity column and also configurable with the sequence name parameter. now you should be able to create a row on the employees table with this simple call: Best regards |
Hi @ogobrecht
I would suggest:
Thanks |
Hi Jacek, here the changes from the weekend:
I hope it is now working for your use case. The thing with the missing data types was clear. The weekend before I had not enough time and I wanted first to hear from you if the solution with the helper functions is generally ok for you, before I spend more time to improve it. If someone needs special handling for the own business he/she can grab the functions and implement the special business logic in an additional helper package. I recommend also creating a wrapper function for the standard APIs in a company to be able to create APIs with a short one-liner. Best regards |
Thanks for the update. I will give it a try and let you know. Best regards |
Hi Jacek, the new version 0.5.0 is out - it took a long time... The relevant parameter for your testing functionality is named Hope you are able now to use it as expected for your tests. And sorry for the long time it took to the version 0.5.0, the changelog for this version is huge... We have currently only simple, SQL script based tests implemented. The next steps are utPLSQL tests, set operations and logger integration. Please let us know any comments or questions and please close this issue, if you think your requirements are met. Best regards |
Hi Jacek, the new version 0.6.0 is out. I implemented some improvements for the dummy data generation when you set the parameter p_enable_custom_defaults to true (generated methods create_a_row, read_a_row, get_a_row). Please have a look in the parameter docs. Since we have now bulk processing this might also interesting for you: bulk processing performance (we use here also your requested function get_a_row...) Please let us know, if we can now close this issue or close it by yourself. Best regards |
I see great and ability to use this API as part of utPLSQL v3 to generate setup/cleanup API's for unit tests.
The only thing that is missing is ability to pass default values for all attributes for insert API.
I'm looking for an API that would insert a row and return inserted data.
The insert row API should require 0 parameters (insert a default dummy row into specific table).
It should also expose all attributes of row to be set if needed.
Example of generated API signature I'm thinking of:
So then in my Unit Test I can call:
I was thinking that your generator API could be extended to accept additional parameter
p_default_values_crsr sys_refcursor
so that it could be used like this:Do you think it would be something fitting into your API project?
The text was updated successfully, but these errors were encountered: