cmeeren / Facil

Facil generates F# data access source code from SQL queries and stored procedures. Optimized for developer happiness.
MIT License
140 stars 7 forks source link

multiple tables without primary keys? #43

Closed WillEhrendreich closed 1 year ago

WillEhrendreich commented 1 year ago

Hey, i am interacting with a SQLServer db that has a ton of tables that have absolutely no primary key.

yeah.. it's exactly as awesome as you might imagine..

anyway, I'm curious what i'm supposed to do to exclude the tables? I can't seem to give it a yaml array to the exclude multiple things, it seems like it wants a regex? i don't really understand how to list individual tables via regex..

also, when i give up on that and ask that it only give the _All output instead of including the byId, i get an exception that sayes error getting outputcolumns for facil-generated table script script ccavgview_All. but that doesn't give me any idea of why or how to fix whatever it's upset about?

what is going on, exactly?

cmeeren commented 1 year ago

A regex that matches only one table is ^MySchema\.MyTable$. You can use this pattern in several include keys to include all the tables you want, and nothing else. Does that help?

If instead you want to include everything except some select tables, you can include: '.*' and then, on the same element, except: MySchema\.(MyTable1|MyTable2|MyTable3)$ etc. (Assuming that all your tables are in the same schema. If not, you need to modify the regex accordingly.)

If this does not help, I need exact details. What are schema/table names of tables you want to include/exclude, whether you're talking about table DTOs or table scripts, exactly what you have tried that doesn't work, which result you expected, etc.

(Note that none of the above has anything to do with primary keys. I understand the lack of primary keys to only be your motivation for excluding certain tables.)

WillEhrendreich commented 1 year ago

Hey, you're so helpful, thank you so much. I appreciate you giving an example of how to exclude those, I am so unfamiliar with regex.

Honestly you didn't have to do that, you could have just said "learn to 2 regex, noob" or "git gud". But you didn't, thank you!

Ok so, I was just trying to get in and have it start working, get my feet wet using it for now. But then I was going to try to figure out the lack of primary key thing, because the tables I have to work with might be at least some of the ones without primary keys.

Some of the times it was complaining about are actually because I don't have access to certain views, and it was just kicking the whole process because of that. those are luckily not something I think I'm going to have to work with, but it didn't give me any indication that it was because of a permission error, and I'm wondering how much people run into that.

I wonder if there's a way to get it to skip things it has errors on and like... give a report about what did and did not work?

Anyway, thank you so much for the quick explanation on the regex thing, I was so confused.

cmeeren commented 1 year ago

Happy to help. I understand your comment to mean that your problem with Facil is resolved, so I will go ahead and close this issue. Let me know if that was incorrectly interpreted!