Releases: leafo/lapis
Releases · leafo/lapis
Release list
v1.9.0
Changes
Widget\includeis now implemented completely different: A dynamic mixins class is generated and inserted into the class hierarchy of the widget whenincludeis first called. All fields and methods from any included classes are copied into this mixin class.- It's now possible to override a method that is provided by an included class. (The current class has higher precedence than the mixins class)
supercan be used to call the method provided by the included by the class when overriding- Some undocumented functionality regarding method merging was removed
- Only one mixin class will be inserted, and all included classes will copy their fields into that class. The most recently included classes will override anything that has the same time. (Note: there is no hierarchy for multiple includes, so you can't use
superto call through multiple included classes) - Methods from the class hierarchy of the included class are also copied into the mixin class. (Note: methods are copied, and the hierarchy is flattened, meaning methods that depend on super may not work as intended)
- Note: The "dynamic mixin class" approach is also used for models when relation methods are generated
lapis.spec.request.stub_requestno longer creates an anonymous app subclass, instead it will override the dispatch method on an instance of the class before stubbing the requestlapis.spec.request.mock_actionwill no longer push thetestenvironment on every call, but instead will use the current environment. (Note: v1.8.2 added autodetection of busted to ensure specs are always running the test environment, so it's not necessary to manually set the environment)
Additions
- Add support for
on_invalid_methodoption torespond_to fetchrelation can be set totrueto autogenerate aget_method based on the providedpreloadfunction- Added support for optional reloations with
db.preload. Relation names prefixed with?will be ignored if the object being preloaded does not contain a relation with that name.- For example, trying to preload the relation
hellowhen the model does not havehellowill result in an error, but preloading?hellowill do nothing. - Optional
?relations can have nested preloads, if the relation is not found then none of the nested preloads are loaded. This works best when combined with polymorphic relations where the objects may not all share the same relation interface.
- For example, trying to preload the relation
Fixes
- Lazy loaded actions work correctly when merged from sub applications
- Before filters work correctly with lazy loaded actions
- Lazy loaded actions work with Lua method responders
Misc
- Default error page has encoding set to UTF-8
- Simplify implmentation of
preload_relations, deprecate it - Optimize concatenations
db.encode_values - Improve error messages for some functions
db.encode_assigns,db.encode_clause,db.encode_valuesthrows error on empty table instead of generating invalid SQL from empty tablesorted_pairsspec helper- Additional specs (
respond_to, widget including, lazy loaded actions)
v1.8.3
Additions
- Support lazy loading route actions from route name to module name #710
- Add UTF8 helper module,
lapis.utf8, for identifying single UTF8 chars and whitespace (lpeg patterns that can be used for trimming and sanitization) - Add
cascadeoption to postgres drop index schema function
Changes
- Remove unused
mimetypesdependency - If
yield_errororassert_errorare not captured by a outer coroutine then a hard error will happen Request\add_paramsdoes not need a name- When searching for OpenResty installation, also accept a binary named
openresty(for openresty install on mac with brew) - pgmoon connection error messages are prefixed with "postgres" to make them easier to identify
- remove excess
;characters in generated SQL for some postgres schema functions - Postgres create index schema function
if_not_existsoption will now use the sql clauseif not existsinstead of running a query to see if the entity exists
Misc
- Update test suite to GitHub actions, remove TravisCI. Test suite works across all versions of Lua
- Update docker test suite to latest postgres/mysql
v1.8.2
Additions
db.deletecan take additional arguments forRETURNING,Model\deletemethod also supports additional arguments to control returning clauseget_X_paginatedmodel relation method now supports passingwhereandorderoptions to the paginator constructor
Fixes
- Using
orderandgroupat the same time withModel\include_inwill no longer generate an invalid query - When running
lapiscommand, the environment is immediately loaded when checking what commands are available for the server, fixes #665 lapis.nginx.cachecan correctly serialize array and boolean types that can result from parameter parsing, fixes 683- The substring
-is no longer matched by accident for route pattern filters #696
Changes
- When running in
busted, thetestenvironment is set as the default environment any tests are run. It is not longer necessary to have asetuporuse_test_envcall to configure the environment - Default buffer size and timout for parsing multipart form data has been increased to allow for slower connections (4k bytes per 5 seconds)
- All logging goes stdout when not running in Nginx
- Compatibility patches for Lua 5.2, 5.3, 5.4
- Improved error message for some
lapiscommands when using an incomplete configuration - Improved error message when file can not be written when generating app files
- (Internal)
default_environmentfunction moved tolapis.environmentmodule, addedset_default_environmentfunction - Better error message when trying to use
belongs_towith composite key (has_oneshould be used instead) - Better error when trying to use default composite primary key with a
has_onerelation
Misc
- Test suites run across on all versions of Lua on GitHub actions
- Added docs for how request parameters are parsed and merged
- Added docs for how the default environment works
- Fixed bug in docs generator where code snippets were not appearing
- The
--traceoption for thelapiscommand is enabled by default when running in test - Fix minor typos in docs
v1.8.0
Deprecations
- The
flipandlocal_keyused withinclude_inor any relations are now deprecated. Replacement syntax available in documentation forModel\include_in
Additions
- Add support for a column mapping table when specifying the key for
include_inand any relations. See more documentation forModel\include_in - Add support for composite foreign keys with
include_inand relations each_itemmethod for Paginators that will return a Lua iterator for going over every row but queries in batches set byper_page- An
orderedoption can be passed toModel\paginatedanget_X_paginatedto create anOrderedPaginatorinstead of aOffsetPaginator - Add
skip_renderaction render option to prevent Lapis from writing anything (Suitable for manually writing to output buffer with something likengx.print) fetchrelations can now specify if they return a collection of items withmanyso nested preloading can traverse the loaded objects- add
servealias for thelapis servercommand line command - add
app_onlycode cache option for cqueues to attempt to load app on every dispatch - A
resty_mysqlobject can be included in the MySQL configuration object to provide additional parameters when initializng aresty.mysqlconnection - Pgmoon connections will now read the
timeoutfield from the PostgreSQL config object (Contributed by turbo 679) - Add
set_loggerandget_loggerfunctions to thelapis.db.mysqlandlapis.db.postgresmodule - (
lapis.db.postgres)escape_identifierfunction will now flattendb.listobjects into raw SQL - (
lapis.db.postgres.schema)create_indexsupport aconcurrentlyoption to create index concurrently (Contributed by Michael Ball 659) - add
testvalidation for manually specifying a function to test input
Changes
assert_errorwill now fail witherrorif the error it yielded was not captured and execution attempted to continue- initial project templates use
content_by_lua_block(Contributed by ryanford 674) each_pagemethod on paginators no longer allocates a coroutine, a plain function iterator is used- attempting to preload an object that isn't a class will throw an error
- attempting to use an invalid order with
OrderedPaginatorwill throw an error measure_performancenow works even when outside of nginx when reporting query time- (
lapis.html)classnamesignores empty strings and will return first argument directly if passed a string - (
lapis.logging)querylog function can now take a prefix and duration - Removed undocumented
localsaction render option
Fixes
- Fix bug where internal shell_escape function would strip
'characters - Returning
{ json = false }in action render will actually render false as json instead of skipping json render
Documentation
- Started rewriting how options tables are described in the documentation. Uses a grid layout with collapsing examples.
- Many parts of Models documentation have been rewritten for clarity
- Remove outdated references to fields that are deprecated/removed (eg.
cmd_url) - Add documentation for the
timestampoption formodel\update - Updated colors of site to be blue
Misc
- Specs now run on GitHub actions with matrix for LuaJIT, OpenResty's LuaJIT, and all versions of Lua
- We now have a MoonScript Discord, join here: https://discord.gg/Y75ZXrD
- Fix typo in docs from Chris Tanner 621
- Fix typo in docs from TangentFoxy 634 685 672
v1.7.0
Changes
- Replaced the CSRF implementation, removed the
keyparameter and replaced with it randomly generated string stored in cookie. - Sessions now use the
lapis.encodingmodule to encode an decode. Session loading error messages have changed to include the error fromencode_with_secretanddecode_with_secret - Remove all support for luacrypto, luaossl is required
Additions
- Add support for chaning HMAC function, add sha256 HMAC config option
- Support parsing cookies when there are multiple cookie headers
- Add
enumtype fro MySQL - Add support for encoding NULL and empty arrays for
to_jsonand JSON render - Add config template for cqueues/lua-http support
- Request object for cqueues/lua-http contains all the same fields as OpenResty counterpart
- Performance object is available for cqueues/lua-http
- Environment name is shown on server start log
- Add
bind_hostconfig option to set which interface cqueues/lua-http binds to, defaults to0.0.0.0
Fixes
- Fix issue with MySQL migrations where query result was not being converted to number
- Fix a crash when request args could not be parsed
- Fix a crash when the query parameter type changes when being parsed (between table and literal)
json_paramsworks with cqueues/lua-http- cqeueus/lua-http test server now works correctly, is now part of CI
- cqeueus/lua-http will no longer get stuck in infinite loop when port is already taken
- cqeueus/lua-http will only ready & parse body for form encoded content type
- Terminal output buffering is disabled for cqeueus/lua-http so service files can read logs from stdout/stderr
Lapis 1.6.0
Additions
- Add a new general purpose
preloadfunction that can preload many relations
at once for many kinds of model instances, including recursively preloading relations - Addition of
cqueuesandlua-httpserver backend - Pgmoon connection status is logged to performance table for each request when
performance measurements are enable fetchrelations can provide a method for preloading with thepreloadoptiondefault_url_paramshas been added to request support object for extending the default parameters passed into `url_formatches_patternvalidation can be used to test an input against a Lua patternrelation_is_loadedfunction can be used to test if a model has a relation loadedmock_requestcan insert a session via a Lua tablelapis.timemodule with asleepfunction that executes correct implementation for the current backend server- If you use
wheninstead ofwherewhen creating an index an error is thrown lapis.spec.request, themock_requestfunction supportscookiesoption- Add
render_to_filemethod for widgets - Add documentation for
Flow
Changes
- Route precedence sorting now uses a score based approach where multiple variables or splats can affect the final order
- Mocked requests have
ngx.md5implemented withluacrypto - Query logs use luasocket to measure time elapsed for a more accurate measurement
- URL parsing uses
findandsubinstead ofmatchto parse very long paths faster (#498) db.NULLvalues are always stripped when inserting a new row from a model'screatemethod- Test server can be run even if there isn't a database configured
- Refactor backend implementation to be extensible to allow for
cqueues/lua-httpimplementation - Add support for test server to run on cqueues backend
- Replace
luacryptowithluaossl
Minor changes
- Lua and MoonScript are added as mime types in default
mime.typesfile (#513) - Various improvements to the documentation
Fixes
- Encoding a query string with a parameter with a boolean value will no longer throw an error
- Fix issue where
*.luawould be included in.gitignorefor Lua projects (#501) - A user set content type will no longer be overwritten when outputting with the
jsonaction return handler - Check for
Content-Dispositionheader for file uploads is no longer case sensitive
Note on cqueues/lua-http
With this release we're adding a new server backend for Lapis. Although the
backend is functional, there are some things that aren't available yet.
Database connections are shared across all requests so you have to be careful
about leaving transactions or state open. Additionally, there's no way to spawn
multiple workers. For production environments we still recommend OpenResty.