« first day (1936 days earlier)      last day (1244 days later) » 

6:03 PM
> string SuperEmails = "";
Some people would say to use string.Empty.
I don't have a problem either way, really.
if (SuperEmails.Length > 0)
{
    SuperEmails = SuperEmails.TrimEnd(SuperEmails[SuperEmails.Length - 1]);
    string Operator = Logr.Field<string>("Operator");
    string FIRST_NAME = Logr.Field<string>("FIRST_NAME");
    string LAST_NAME = Logr.Field<string>("LAST_NAME");
    string PartNumber = Logr.Field<string>("PartNumber");
    string WorkOrder = Logr.Field<string>("WorkOrder");
    string SubId = Logr.Field<string>("SubId");
    string Operation = Logr.Field<string>("Operation");
    int AvailableQuantity = Logr.Field<int>("AvailableQuantity") - (Logr.Field<int>("ExistingGoodQuantity
I'd pull the body of that if into a new method.
 
@KySoto the exact same reason you don't code an entire VBA macro in Macro1 ;-)
 
Then you have:
if (SuperEmails.Length > 0)
{
    DoWhatever();
}
else
{
    Console.WriteLine(...);
}
You might want to clean your indentation up some.
const string Server = "Redacted";
const string Database = "Redacted";
const string SMTPServer = "Redacted";
That should go into a config file.
I'd move your SQL to the DB as a stored proc, maybe.
The body of if (LogDataset.Tables[0].Rows.Count > 0) could also be moved to its own method.
Looks pretty good otherwise (besides my bleeding eyes from the naming :P).
 
6:36 PM
RD question - is there an inspection that flags a missing End If causing a Next w/o For error?
 
@MathieuGuindon Thanks Mug, exactly what I needed.
 
@BigBen does a parser error count?
Love that indenter, that goes onto the permanent bookmark list. It doesn't highlight bad code, though, you have to notice that your NEXT is now lined up with an IF rather than the FOR statement above it. — Roy Brander 10 mins ago
^ nice!
 
@MathieuGuindon now if the indenter worked off the parser ....
 
...then it would need to skip error nodes? :)
 
so we currently have 158 prereleases overall. Thereof 51 are from the 2.3 cycle
of those, 13 are from 2.3.0
 
6:50 PM
no wait, we don't even cache the parse trees for non-parsing code, do we?
 
nope.
 
kind of a bummer
 
currently when parsing fails, we don't even attempt to recover, IIRC
 
we need to implement parsing recovery before the indenter can work off of it
 
yeap
I think I'll delete the 2.3.0 and 2.3.1 prereleases now, any objections?
 
6:55 PM
not from me :)
 
You're more likely to get objections if you announced you weren't :D
 
:)
 
I OBJECTT!!! How are we going to get to sing ♫200 RD releases on GH, 200 RD releases! Load one down, Install it now, 199 RD releases on GH!♫ ?
 
@FreeMan Uh, you can't anyway....
 
Objection dismissed ;)
5
 
6:57 PM
Because loading it down doesn't remove it.
So you'd be stuck at 200 anyway.
 
y'all missed the point. yer no fun.
 
DB data types. Where's the string data type?
 
@FreeMan I saw the point. I just ducked so I wouldn't get it.
@IvenBach Wouldn't it be nvarchar(#)?
 
Also, calling back yesterday and Friday's conversations about email addresses, I just discovered one with a space in it! Of course, there are no surrounding "", so I'm 100% sure it's unintentional, but I found one!
 
Where # is the number of characters the string can hold?
 
6:59 PM
No clue. That's why I'm asking.
 
@FreeMan LOL.
 
@IvenBach In Access it would be Text in SQL Server it would be char, varchar, nchar or nvarchar, and yes, (#) determines the max string length all the way up to (max) which, as I understand it, is roughly 2 billion characters.
 
@RoyBrander awesome! Hopefully you're using the actual VBIDE add-in as well! FWIW the indenter currently isn't working off parse trees (lots of work needs to be done for that to work), but when it does, it should be able to recover the "mismatched 'Next' input, expecting {bunch of tokens}" parser error and, indeed, somehow highlight or otherwise identify the "Next" error node. Actually fixing the problem automatically requires mind-reading capabilities that Rubberduck won't have in the foreseeable future though ;-) — Mathieu Guindon 2 mins ago
huh, 907 - we got un-starred again
 
is there a better way:
DayPhone = CASE
  WHEN LEN(source.DayPhone) > 0 THEN Source.DayPhone
  ELSE NULL
END,
there has to be a better way...
 
@FreeMan NullIf
 
7:03 PM
d'oh
escorts self to door
 
eh, ifnull, nullif, isnull, is null, ...easy to get lost
 
yeah... but... from the docs:
> Remarks NULLIF is equivalent to a searched CASE expression in which the two expressions are equal and the resulting expression is NULL.
you know, like, if I'd read the page I'd opened about 4 hours ago...
 
@FreeMan <pedant> Access' Text is equivalent to nvarchar. Access does support nchar but not via the UI. Access doesn't do non-Unicode, so not possible to have either char nor varchar ATM. </pedant>
 
Here's a pendant for the pedant: cdn.pixabay.com/photo/2015/04/20/17/00/…
 
<petulant pedant>But I'm a boy!</petulant pedant>
 
7:14 PM
and now you can be a real boy!
 
He has a nose... Like a hose...
(Reminds me of the Corries song called "La-di-dum".)
 
Can a data type of a column in a table be changed at a later date?
 
sure.
whether there's data loss is another matter, however.
 
Kind of.
 
usually, widening changes are OK
 
7:17 PM
@this that
 
You can't change a Money to an Integer, for example.
 
narrowing changes... caveat ususario
 
Often it's a drop/re-add.
 
^
 
It's not easy to change the types.
 
7:18 PM
the type change has to be compatible at least.
 
or build new table with correct structure, migrate data to new table (with necessary conversions), drop old table, rename new table to old name
 
nvarchar(20) => nvarchar(255) A-OK
nvarchar(20) => int ?!? Maybe?
 
X * 20 = Y Where X is "X", solve for Y
 
20X
 
^
 
7:20 PM
VBA-landia taught me that.
 
no, it's "X * 20"
approximately
 
Nuh-Uh. Has no " around it so's not valid.
 
x * 20 = 20x
not sure what you mean by " anyway
 
but not if x = "x"
TypeOf(x) = string
 
that's not math.
That's just dumb programming
 
7:22 PM
exactly:
3 mins ago, by this
nvarchar(20) => int ?!? Maybe?
 
In that case, it would only succeed if all values in the column happened to be numeric
or null
 
I was making a demonstration of your most excellent, pedant, pendant, point
 
I don't follow, though. if you stored X * 20 in the column, that's a string and thus can't be converted.
 
that was my point. "x * 20" = "x * 20", not 20x
sigh...
 
do I get bonus points for killing the point?
 
7:26 PM
Yes. I award you enough bonus points that you can now redeem them for one magical unicorn fart. Prepare to capture it from your USB port in 3... 2... 1...
 
I'm going to kill the fun and say we have to kill all the unicorns because their farts are causing global warming, just like the cows.
 
uh-huh
 
at least kill them cleanly so we can sell unicorn steaks at bargain prices
 
Now that's "beyond meat"
 
Unicorn --- the real white meat
 
7:29 PM
you sure it's white, not rainbow colored?
 
well if it's rainbow-colored, it's white.
 
^ TROLOLOLOLOL!
 
That said, we've had 2 tornadoes in Quebec this year. Tornadoes in Quebec in my lifetime: most certainly less than 5
 
#fun
 
Better cancel any plans that takes you into vicinity of any trailer parks, then.
 
7:31 PM
Floods too, in places that had never been flooded before
 
@MathieuGuindon The US already has a Pineapple for a president. Why are you surprised by anything?
Derp check. Should I bother with typing the fields in the DB or just got with nvarchar to start?
 
@IvenBach yeah don't bother typing. store everything in nvarchar byte arrays, life will be much simpler!
data types are for the weak!
 
I legitimately can't tell if that's dry sarcasm or not.
 
~.~ that confirms it.
 
7:34 PM
at the end of the day, everything's one or zero.
 
Not helping.
 
well, there might be one or two 2s
funny because I'm reading CJ Date's book and he's making the point that DBMS type systems are basically crap
But I digress.
 
You do want to have most narrow data types that your data model needs, IMO.
meaning, if you care only about dates and not time, use date
 
I want to get a table build to test. Performance can come after I've failed and realized there's a bottleneck.
 
7:37 PM
for texts, it's a bit hard because we seldom have any irrevocable constraint.
Sure, you might have a 20-character code today but tomorrow, it's now 24 because #reasons
 
^
I already know that's going to happen.
Right now I'm just setting up the numeric fields.
 
But in that case, I'd just use char(20). It's cheap to convert to char(24), provided you widen sanely.
Do yourself favor. Don't ever use floating precision.
That's your expressway to hell
 
Since I'm working with en-us locale is there any reason to care about nchar?
 
That's what everyone says.
 
Meaning stick with decimal and numeric?
 
7:39 PM
Oops! We now have a guy named Averuño!
Yeah
 
Mumble mumble point proven nvchar mumble...
Derp check: Can table fields be typed to an Enum?
 
not exactly.
what I do in this situation is to create a code table
that table would have a regular int as the PK and not have an IDENTITY attribute
then I build an enum based on that table's code key
We have a convention where such table should not use ID as the name but rather Code as the name and as the PK, to help remind that it's a code table and thus the numbers have programmatic meaning
 
7:54 PM
@IvenBach It's not that expensive to type the extra n, and it's really not expensive to store the extra byte per char. It is expensive to lose data or restructure later.
 
^
 
Yay! conference call with tech support time! Maybe we'll get this whole API issue sorted out in the next 30 minutes.
 
don't forget your 2x4 cluestick!
 
Everybody get to be ncharchar then, even the numbers!
 
ncharchar?
so that's a nchar stored in char?
Mind boggles.
 
8:03 PM
#Words: nvarchar
#TIL: A primary key or index cannot have more than 16 columns.
 
;-)
@IvenBach uh.... you shouldn't ever need that many columns....
 
@IvenBach denormalized much?
 
Parametric sweep.
I think it's 13 or 14 columns that consist of the PK
 
... why not use a surrogate key?
 
What's that? Remember I've only derped my way through DB before.
 
8:14 PM
and if you have that many columns that's "unique" collectively... chat.stackexchange.com/transcript/message/51821457#51821457
 
I truthfully don't know what I'm doing.
 
Surrogate key => you make up your own key
usually by creating ID int NOT NULL IDENTITY CONSTRAINT PK_table CLUSTERED
 
what columns do you have in your table?
 
A column that's not allowed to be Null that's not auto populated?
 
8:16 PM
the 13 or 14 columns make up a rather annoyingly large Natural Key - you don't want that as your primary key, unless you enjoy join clause hell
 
It is auto-populated.
That's the purpose of IDENTITY attribute
 
@this I always explicitly set the identity seed: identity(1,1)
 
Interesting. I've never had to do that (and hadn't a good use case for not using 1,1 as the seed either)
 
@this I just don't like implicit args :)
 
Fair enough.
 
8:17 PM
(also anything but 1,1 is criminal IMO)
 
wonders how many DBA out there actually dare to use seeds that's not 1,1
 
so anyway, the natural key (NK) is a bunch of columns that, taken together, make a record "distinct" or "unique". if the NK is also the PK, then you need to use every single one of these fields in every single join ever. So you make that NK into a unique constraint, but define your own surrogate key (SK) as the table's PK
 
^
 
@this probably only in Craver's "bad ideas" repo
 
but even so, 13-columns as a NK seems suspect
 
8:20 PM
indeed
10 mins ago, by Mathieu Guindon
@IvenBach denormalized much?
 
LOL
 
SaveName
HSSBeamSectionSet
HSSColumnSectionSet
WindRiskCategory1
WindRiskCategory2
WindRiskCategory3
SeismicSs
SeismicS1
RFactor
ColumnSpacing
PurlinCantilever
Angle
Width
ColumnLocation
ColumnHeight
SnowLoad
HSSBeamMaterial
HSSColumnMaterial
SimpleSpanBracing
CantileverSpanBracing
WeakWindAxisDeflection
SeismicWeakAxisDeflection
Purlin
 
bingo
this is all kind of wrong
 
WindRiskCategory1
WindRiskCategory2
WindRiskCategory3
^ is staring at me
 
Slap an ID on there.
That shouldn't be all the key.
 
8:22 PM
there's also the SeismicSs and SeismicS1
 
WindRisk has 3 different categories that need to be tracked.
 
And the Deflections.
 
@IvenBach today. now you need to track a 4th.
 
And SectionSet.
 
8:22 PM
`HSSBeamMaterial`
`HSSColumnMaterial`
are possibly suspect, too
 
@MathieuGuindon Nope never. Don't use that one. :p
 
@IvenBach the point here is that a table must represent a single entity
and you have several attributes that doesn't feel like they belong to a single entity
 
So take WindRiskCategory[1-3] and create a table from that linking via a PK?
 
yeah
 
mumble mumble 10 years mumble last faked db mumble
 
8:24 PM
Excel can be quite brain-damaging when it comes as a basis for data model, unfortunately
so you have to unlearn a lot of things that comes naturally in Excel
 
@IvenBach ok, put it this way then: how many times are you storing the value for WindRiskCategory[2] if there is a billion records in the table?
(don't count)
 
11billion times for the 11 billion records.
Spread across ~22 workbooks with 500,000 rows each.
 
@IvenBach so, if that's a nvarchar(20), that's 11 billion times up to 40 bytes. compute that, and compare to 11 billion times the 4 bytes of an int.
 
2 mins ago, by IvenBach
mumble mumble 10 years mumble last faked db mumble
 
a simple maxim for you to go by
columns are expensive, rows are cheap
 
8:28 PM
^
 
well, I've officially got tech support stumped!
Yay me!
2
 
They were, however, putting request parameters in the body, not in the request headers in postman, so my task it to try that to see if it makes a difference in my code. They're looking into other things as well. We're reconvening tomorrow...
 
> Hi, we've looked at your request, looked at our API, and concluded that our API makes no sense and will be getting back to you shortly - as soon as we've rewritten the $#!t out of it.
#NotGonnaHappen
 
@MathieuGuindon one could only hope...
 
8:37 PM
> Please subscribe to our newsletter for all the updates!
 
> BTW, we don't use the API ourselves. Because we write directly to our DB, just as the cool kids should do.
 
I feel so dumb. Can't remember how to set up a PK to FK. :reaches-for-manual:
 
(i.e. 14-column PK joins in plain T-SQL string literals all over the code)
@IvenBach alter table [Table] add constraint FK_[Table]_[Other] foreign key [ThingId] references [Other] (Id)
 
alternatively, CREATE TABLE [table] ( .... [ThingId] int CONSTRAINT FK_[Table]_[Column] FOREIGN KEY REFERENCES [Other] (Id) ... );
 
@this actually, how I script my tables is Id int identity(1,1) not null, and then I do alter table ... add constraint PK_TableName primary key clustered (Id)
 
8:43 PM
(note that the [ThingId] is omitted in the alternative syntax since constraint is defined inline.
 
from a couple of days ago, sending request parameters in the body be like:
{
  "startDate": "2019-09-18T00:00:00-05:00",
  "endDate": "2019-09-18T23:59:59-05:00",
  "locationId": [
    106
  ]
}
 
I typically define my constraints inline because it makes for more compact scripting and easier to see what's what at a glance
 
but the formatting is just for you & me, the 'puter don't care about the CrLf right?
 
shouldn't, no.
 
ass-u-me-ing that's for me, thx
 
8:44 PM
@MathieuGuindon I need more breadcrumbing than that. Reading Primary and Foreign Key Constraints to educate myself.
 
@this ha, I like scripting the constraints separately (esp. FKs), precisely because it makes it easier to make the script drop constraints at the top, then drop the tables, then create the tables and their respective constraints, then the procedures, ...
basically I like having a 2-3K liner script that I can just hit F5 on and nuke/re-generate the entire db
 
but I don't see anything that prevents you from doing that even with the inline definition.
 
nothing
 
e.g. I still write the drop constraint + drop table at the top, then the create table with constraint inlined
 
it's just easier to copy the alter table / add constraint to the /* drop constraints */ part of the script :)
#IveBadHabitsToo
 
8:52 PM
Right. In my case, I'm afraid that I'll forget to copy those
inline help make sure I don't forget
 
eh, when I can't hit F5 twice in a row and get a clean run, I know I messed it up
 
but how do you know it's not missing a constraint it should have?
that won't be caught by running f5 twice?
 
because the constraints are right under the table defs :)
create table shop.ProductOptions (
	 _Id int identity(1,1) not null
	,_AppId int not null
	,_DateInserted datetime not null
	,_DateUpdated datetime null
	,_ProductId int not null
	,ShopifyId nvarchar(128) not null
	,OptionIndex int not null
	,OptionName nvarchar(255) not null
	,OptionValue nvarchar(255) not null
);
go
alter table shop.ProductOptions add constraint PK_ProductOptions primary key clustered (_Id);
alter table shop.ProductOptions add constraint NK_ProductOptions unique(_AppId, ShopifyId, OptionValue);
in other news, I think I'm developing a thing for underscores in my SQL tables, and I don't know if it's a good thing or not.
 
doesn't that require you to bracket it?
 
8:56 PM
huh. #TIL
Personally I avoid the underscores because #SaveThePoorPinky
 
Ugh.
 
I find it makes it plain obvious what data is generated by me vs what's coming from the API
 
Underscores are the spawn of he-who-must-not-be-named.
 
otherwise ShopifyId looks like any other FK column, and there's really no better name than ShopifyId for that value
 
but doesn't Shopify already tell you taht it's not yours?
 
8:58 PM
it does
@Hosch250 sure, except if there's any underscore in a select list, you know you're selecting something you shouldn't be
 
Uhhh.
If it's write-only, then why store it?
 
Dim foo As String: foo = "bar": foo(1) = "c": debug.pring foo will not yield "car" will it.
 
_DateInserted and _DateUpdated are control fields, VERY useful.
 

« first day (1936 days earlier)      last day (1244 days later) »