Is there any things that I probably could help?
Hi there!
I'm really interested on this ORM library since this brings SQLite as the DB (because I just got hooked up with recently) and moreover, I'm also down to developing my skills! I might be not that on Senior level but I think I could help with something or probably just learn something new instead!
But if you don't really seeking for any (serious) help because of personal reasons, that's also okay so, don't worry about it too much. Looking forward to hearing more from you. Thanks mate!
NB: It's not really necessary but, since it's a hacktoberfest month, do you think you'd consider adding the tag?
Definitely! The code is very messy and complicated, so it might be difficult. I am just trying to get features completed rather than worrying about the code looking pretty. This should be the general style of anyone that wants to contribute. Don't worry about the code being perfect, just get things done. I am currently working on adding typing and parsing to json functions. For example,
select json_group_array(startTime) as dates from events limit 5;
was previously just typed as any in TypeScript, as with all other JSON types. It also didn't convert the date to an actual Date object because it just treated it as JSON. Now it is typed as Array<Date> and it maps the array of strings to an array of dates. There are still many more cases like that, such as json_object.
Custom JSON types
The next thing I want to do is make it easy to add TypeScript types to columns that contain JSON. For example, the social column in the fighters table in the test database is JSON. There is a folder in the source code called test that contains the test database and the tests. They can be run with node test.js if you are in the terminal and in the same folder as the test files. What I want to be able to do is let the user specify a dbTypes.d.ts file, which will allow them to define interfaces in TypeScript. The path to this file should be read here:
https://github.com/thebinarysearchtree/flyweight/blob/c5c9e3c34ef8308c7648840bbca1758e911e7f25/src/db.js#L136
If this path is specified, when the types are created with makeTypes, all of the data inside dbTypes.d.ts should be appended to the start of the db.d.ts file. This can be done here:
https://github.com/thebinarysearchtree/flyweight/blob/c5c9e3c34ef8308c7648840bbca1758e911e7f25/src/sqlParsers/types.js#L264
The next part is to allow people to create custom JSON types easily. Currently, they have to include all of the dbToJs and valueTest functions and so on. Maybe the user will do it by:
db.registerTypes([{
name: 'social',
tsType: 'Social',
isJson: true
}]);
instead of having to specify all of the other stuff. Social is a TypeScript interface declared in the dbTypes.d.ts file that they have made.
Download and compile regexp.c
Currently there are just instructions to compile the regexp extension, but I want this built-in. Instead of just including the binary for the extension, I would like the regexp.c and amalgamation.zip to be downloaded from official sources and compiled for the relevant OS. If I just include the binary, it cannot be trusted. I think the user might have to specify a path to put the extension because if I just compile it into the node_modules folder, it will be a problem when trying to create a production build.
Handle multiple types
Some expressions, such as case when then end can return multiple different types. This code here:
https://github.com/thebinarysearchtree/flyweight/blob/c5c9e3c34ef8308c7648840bbca1758e911e7f25/src/sqlParsers/queries.js#L192
only takes one of the case statements and gets the type from that if possible. The column object has a type property. It might need an additional types property.
Handle coalesce
I don't think I handle this function at all.
These are all quite complex and the codebase is complex, but if you want to try any of them, then go ahead!
Hello, Thanks for the reply! I really appreciate it so much!! And I'm sorry for my late reply.
I actually have tried going through this project and run it into my local machine but seems like it always failed because of I can't really get the compiled regexp.dylib version. No matter what I do, I can't compiled the the regexp.c nor the regexp.cpp. I tried to find any article regarding this but seems like there's something to do with my Macbook because I use the Apple Silicon (M1 Pro).
I'm actually so frustrated for the last 2 days lol because I can't get it up running here (all I want is just running the test but why its so hard :( damn).
Any idea about this?
Haha oh no. I knew those extensions would cause problems because of the compilation step.
What are the error messages you encounter? I guess you followed the compilation steps in the readme. I need to try to get access to different operating systems to try to get them to all work. Maybe try compiling the simplest c code you can find and get that to work first.
Alternatively, you can just remove the lines related to the regexp code in the tests and just not worry about installing the extension. Also, make sure you are on the latest version of the code.
Some things to try to get the regexp.c to compile are:
- make sure you have xcode command line tools installed
- try adding -arch arm64 or something like that to the gcc command that you have to run.
- the test code already points to an existing regexp.dylib in the database folder. Make sure to delete that and replace it with the one you compile, otherwise it will seem like it isn't working because that version is for intel macs.
Oh and here is an update of what I have done:
I have added full support for json functions, coalesce, and anything that might return multiple types. I haven't done the custom JSON types or regexp stuff. I am thinking with the JSON types that the user just supplies an interfaces.d.ts, and then whenever the tables.sql files have a type that is not registered and matches the lowercase name of one of the interfaces in that file, then it automatically assumes it is JSON.