Edgardochristinaalicia's Profile

50
Points

Questions
8

Answers
8

  • Either solution definitively will prevent race conditions. SQL databases have atomicity, consistency, isolation, and durability (ACID) properties. The cool thing about SQL databases: you don’t have to worry about race conditions if you get the transactions right.

    Single statement operations like the UPDATE in your second example are always atomic transactions. And, the explicit transaction in your (correctly written) first example is also an atomic transaction.

    Like @GMB, I prefer to use single statement operations wherever possible. But that’s just because the code is easier for the next programmer (or my future self) to understand. Either approach works.

    And, if your business rules get more complex, you’ll probably need multistatement transactions. That’s an advantage of your first approach.

    Both your solutions are ACID-preserving.

    • 44 views
    • 2 answers
    • 0 votes
  • Here is my solution:

    create DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP

    MySQL refused the date to be like this: 0000-00-00 00:00:00

    • 6 views
    • 1 answers
    • 0 votes
  • To pick a latest row per group (sku_parent) you can do self join like

    Schema

    CREATE TABLE logs     (`id` int, `warehouse` varchar(7), `sku_parent` int, `sku_child` varchar(8), `case_balance` int, `date` datetime, `created_at` datetime, `updated_at` datetime) ;      INSERT INTO logs     (`id`, `warehouse`, `sku_parent`, `sku_child`, `case_balance`, `date`, `created_at`, `updated_at`) VALUES     (5, 'SeaWest', 120, '120 - 25', 400, '2020-08-26 00:00:00', '2020-08-26 19:02:20', '2020-08-26 19:02:20'),     (6, 'SeaWest', 121, '121 - 25', 784, '2020-08-26 00:00:00', '2020-08-26 19:02:42', '2020-08-26 19:02:42'),     (7, 'SeaWest', 121, '121 - 25', 734, '2020-08-26 00:00:00', '2020-08-26 19:03:46', '2020-08-26 19:03:46'),     (8, 'SeaWest', 120, '120 - 25', 350, '2020-08-26 00:00:00', '2020-08-26 19:03:46', '2020-08-26 19:03:46') ; 

    Query

    select a.* from logs a left join logs b on a.sku_parent = b.sku_parent     and a.id < b.id where b.sku_parent is null     and a.sku_parent = :sku_parent     and a.date between :from_date and :to_date 

    Query Builder

    DB::table('logs as a')   ->select('a.*')   ->leftJoin('logs as b', function ($join) {         $join->on('a.sku_parent', '=', 'b.sku_parent')              ->whereRaw(DB::raw('a.id < b.id'));    })   ->whereNull('b.sku_parent')   ->where('a.sku_parent', $request->sku)   ->whereBetween('a.date', array($request->from_date, $request->to_date))   ->get(); 

    If you need to pick the latest record base on created_at then change the leftJoin part to ->whereRaw(DB::raw('a.created_at < b.created_at'))

    DEMO

    Laravel Eloquent select all rows with max created_at

    • 7 views
    • 2 answers
    • 0 votes
  • As Asperi has said, it is not possible to have a multiline navbar title by default. So, following Asperi suggestion, I have hidden the default title and I have set a custom Text():

    VStack(alignment: .leading) {                     Text(Constants.Distribution.text)                     .font(.system(size: 34, weight: .heavy))                     .foregroundColor(Color.white)                 } 

    . . .

    .navigationBarTitle(Text(""), displayMode: .inline) 
    • 4 views
    • 1 answers
    • 0 votes
  • Asked on September 1, 2020 in CSS.

    so first of all – as far as i can see – there is only Text on your Document which means there actually cant be a horizontal scroll bar (I cant see the Image – So its probably the Image which is overflowing)

    But anyway, you can try to add this at the top of your css document:

    body: {overflow-x: hidden;}

    if its still adding a scrollbar you can:

    1. Add a Display: None to the @media (which removes the Image completely 😉 ) or
    2. you add width: 100vw to the image

    instead of breaking every single Menuitem you should try this

    HTML:

    <div class="menu">      <div class="menu-item">Contact</div>      <div class="menu-item">Team</div>      <div class="menu-item">About Us</div> </div> 

    CSS:

    .menu {     display: flex; }  .menu-item {     margin-left: 30px; } 

    And can you explain what you mean with "shrink menu heigth"? You mean the "Title" Headline with the grey background?

    • 8 views
    • 2 answers
    • 0 votes
  • Asked on September 1, 2020 in CSS.

    In order for children to match the width and height of their parent element you need to remove all padding and margins from the child element. You can then set the height and the width of the child to 100%. The height and width would then be controlled by the parent element.

    • 8 views
    • 3 answers
    • 0 votes
  • Asked on September 1, 2020 in CSS.

    CSS 3’s box-align property

    #outer {     width: 100%;     height: 100%;     display: box;     box-orient: horizontal;     box-pack: center;     box-align: center; } 
    • 18 views
    • 30 answers
    • 0 votes
  • Asked on September 1, 2020 in CSS.

    The easiest way:

    #outer {    width: 100%;    text-align: center;  }  #inner {    margin: auto;    width: 200px;  }
    <div id="outer">    <div id="inner">Blabla</div>  </div>

    • 18 views
    • 30 answers
    • 0 votes